[thelist] regex help

Frank lists at frankmarion.com
Tue Sep 2 19:49:44 CDT 2003


At 0237 PM 2003-09-02 -0700, you wrote
 >I have what is probably a simple regex to do but i cannot
 >figure it out. Mainly because I need a variable in my
 >regex. Here is my target string

 >string = "s1s2s3s4";

Is this literally your target string? Can you give me more variations?

 >from there, I need to remove say "s3".

 >But the 3 is going to be a variable, say personID. so
 >really I need to remove "s" + personID as my regex.

There's not much to describe your pattern, but here's a best guess based on 
the supplied info:

Almost too obviously:
(s1s2(s[0-9]+)s4)

\1 will return the whole pattern
\2 's3', 's33', 's0239487289743'

This will you would simply do a replace using the procedural language of 
your choice
replace \1 with ''.

But I get the sense that there's more to it. Can you give some real world 
examples of the variables and the desired match?

--
Frank Marion     lists at frankmarion.com      Keep the signal high.  



More information about the thelist mailing list