473,382 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

substitute

GS
what is that best way to substitute in string something like ${somename}
with its corresponding value. procedural wise, stepping through each found
match and replace accordingly

One way in pseudo code:

string str4subs = "something is ${param1}${param2} some other things
${exprk} whatever"; // in real life it may be a lot longer and with more
substitution required
Regex myregex = new Regex("(\$\{\w\}, Regexoptions.ignoreWhitespace|
Regexoptions.multiLine |Regexoptions.ignorecase)";
Match myMatch = new myregex.Match(str4subs)

// oops, I am stuck here as to how to use match group or capture to replace
with the corresponding value

// don't want to iterate all possible pair
I need help here

Apr 22 '07 #1
2 1695
On Apr 22, 7:03 am, "GS" <gsmsnews.microsoft.co...@msnews.Nomail.com>
wrote:
what is that best way to substitute in string something like ${somename}
with its corresponding value. procedural wise, stepping through each found
match and replace accordingly

One way in pseudo code:

string str4subs = "something is ${param1}${param2} some other things
${exprk} whatever"; // in real life it may be a lot longer and with more
substitution required
Regex myregex = new Regex("(\$\{\w\}, Regexoptions.ignoreWhitespace|
Regexoptions.multiLine |Regexoptions.ignorecase)";
Match myMatch = new myregex.Match(str4subs)

// oops, I am stuck here as to how to use match group or capture to replace
with the corresponding value

// don't want to iterate all possible pair
I need help here
It it's a string you might use String.Replace() ? I have no idea about
the performance of it, though.

- Dan

Apr 22 '07 #2
GS
Sine the variable names and values are not fixed but from a database table,
I am inclined to use a dataset with match evaluator, what do you think?

I am now look at using match evaluator. If I have the
"Dan Soendergaard" <da*****@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
On Apr 22, 7:03 am, "GS" <gsmsnews.microsoft.co...@msnews.Nomail.com>
wrote:
what is that best way to substitute in string something like ${somename}
with its corresponding value. procedural wise, stepping through each
found
match and replace accordingly

One way in pseudo code:

string str4subs = "something is ${param1}${param2} some other things
${exprk} whatever"; // in real life it may be a lot longer and with
more
substitution required
Regex myregex = new Regex("(\$\{\w\}, Regexoptions.ignoreWhitespace|
Regexoptions.multiLine |Regexoptions.ignorecase)";
Match myMatch = new myregex.Match(str4subs)

// oops, I am stuck here as to how to use match group or capture to
replace
with the corresponding value

// don't want to iterate all possible pair
I need help here

It it's a string you might use String.Replace() ? I have no idea about
the performance of it, though.

- Dan

Apr 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: francescomoi | last post by:
Hi. I want to substitute a character (e.g. 'R') for another one ('-R') within a word: 'RECORD' ---> '-RECO-RD' Is it possible by using any PHP command? Regards.
3
by: Robert Anderson | last post by:
Hi There! My web site is currently hosted on a commerical hosting server (which is not my own) and they are not allowing me to create my own COM dll and use them with my ASP pages. They are not...
3
by: Alex | last post by:
I need an Epic Editor substitute. I tried XML Spy and it does not meet my needs. I can't afford Epic Editor multi-user license at the moment and I need to render a proof-of-concept for a...
5
by: Gary McCullough | last post by:
What I want to do sounds simple, but it's defeating me. I want to substitute all occurences of a colon : character in a string with an @ character -- unless the : occurs within a single or...
14
by: Glen Able | last post by:
Should it be possible to create a custom class, 'Float', which would behave as a drop-in replacement for the builtin float type? As mentioned in another thread, I once tried this in rather a...
4
by: David M. Gauntt | last post by:
Is there a w3c compliant substitute for window.location? I don't need the full functionality of the location object; just the ability of getting the URL (including the search field). - David...
2
by: Jeff Marcum | last post by:
I need to write a query in Access that returns the results of a text field with the spaces replaced with underscores. So, if the data in the field was 'hello world', the query results would show...
5
by: Steve Richter | last post by:
I have a public variable ( "mZipServiceUrl" ) in my code behind class that I am able to substitute into the HTML of the .aspx file: <span onclick="WindowOpen('<%=mZipServiceUrl%>')"...
4
by: vijay.rajamanickam | last post by:
I am a newbie w.r.t. compiler optimizations and I believe these optimizations are generally done in function level. Can I safely assume that if I use getter & setter functions, I can effectively...
1
by: Rocky Zhou | last post by:
I am accustomed to vi my pthon scripts with 'tab' indent. But when I copy some code to my script, the indent may be 'spaces'. So I wanna a way to substitute those 'spaces' to be 'tabs'...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.