pattern matching and string replacement 
Author Message
 pattern matching and string replacement

Hi,

I have a string (a textfile) where I want to replace some words with another
string.
E.g. I want to replace the substring "server001" with "serverXXX", this is a
very simple task
But my problem is that I also have to replace "server002", "server003" etc.
with "serverXXX".
So I'm looking for a function that takes a string patern as the search
string, e.g.

myStr.Replace("server00?","serverXXX"); //replace the first 10 servers
myStr.Replace("server1??","serverXXX"); //replace the servers 100 - 199

How can I do that?
(I fear that there is no simple approach).

BR
Emil



Sun, 19 Dec 2004 19:01:11 GMT  
 pattern matching and string replacement
wuops, found a solution. Just search for 'regular expressions' in the help
instead of 'patern matcing'.

You can use: System.Text.RegularExpressions.Regex.Replace(...

BR
Emil

Quote:

> Hi,

> I have a string (a textfile) where I want to replace some words with
another
> string.
> E.g. I want to replace the substring "server001" with "serverXXX", this is
a
> very simple task
> But my problem is that I also have to replace "server002", "server003"
etc.
> with "serverXXX".
> So I'm looking for a function that takes a string patern as the search
> string, e.g.

> myStr.Replace("server00?","serverXXX"); //replace the first 10 servers
> myStr.Replace("server1??","serverXXX"); //replace the servers 100 - 199

> How can I do that?
> (I fear that there is no simple approach).

> BR
> Emil



Sun, 19 Dec 2004 19:17:47 GMT  
 pattern matching and string replacement
well 'pattern matching' would be better than 'patern matcing'  :-)

Quote:

> wuops, found a solution. Just search for 'regular expressions' in the help
> instead of 'patern matcing'.

> You can use: System.Text.RegularExpressions.Regex.Replace(...

> BR
> Emil


> > Hi,

> > I have a string (a textfile) where I want to replace some words with
> another
> > string.
> > E.g. I want to replace the substring "server001" with "serverXXX", this
is
> a
> > very simple task
> > But my problem is that I also have to replace "server002", "server003"
> etc.
> > with "serverXXX".
> > So I'm looking for a function that takes a string patern as the search
> > string, e.g.

> > myStr.Replace("server00?","serverXXX"); //replace the first 10 servers
> > myStr.Replace("server1??","serverXXX"); //replace the servers 100 - 199

> > How can I do that?
> > (I fear that there is no simple approach).

> > BR
> > Emil



Sun, 19 Dec 2004 19:37:33 GMT  
 pattern matching and string replacement
:))))))

Quote:

> well 'pattern matching' would be better than 'patern matcing'  :-)


> > wuops, found a solution. Just search for 'regular expressions' in the
help
> > instead of 'patern matcing'.

> > You can use: System.Text.RegularExpressions.Regex.Replace(...

> > BR
> > Emil


> > > Hi,

> > > I have a string (a textfile) where I want to replace some words with
> > another
> > > string.
> > > E.g. I want to replace the substring "server001" with "serverXXX",
this
> is
> > a
> > > very simple task
> > > But my problem is that I also have to replace "server002", "server003"
> > etc.
> > > with "serverXXX".
> > > So I'm looking for a function that takes a string patern as the search
> > > string, e.g.

> > > myStr.Replace("server00?","serverXXX"); //replace the first 10 servers
> > > myStr.Replace("server1??","serverXXX"); //replace the servers 100 -
199

> > > How can I do that?
> > > (I fear that there is no simple approach).

> > > BR
> > > Emil



Sun, 19 Dec 2004 22:44:45 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Regular Expressions/Pattern Matching/Unordered pattern

2. Request for Sample Code in case sensitive pattern matching of string in C

3. Help on string pattern matching?

4. Pattern Matching in C -

5. Pattern Matching Tool

6. Pattern Matching in C

7. Help, Pattern used in Regex.Matches(...)

8. help with a fast pattern matching utility requested

9. Pattern Matching in execution time

10. pattern matching with the function glob.

11. Performance while regexp pattern matching

12. pattern matching in c

 

 
Powered by phpBB® Forum Software