We don't bite newbies here... much | |
PerlMonks |
Re^3: Howto strip 42 from comma separated list using s///by ady (Deacon) |
on Dec 16, 2005 at 10:26 UTC ( [id://517200]=note: print w/replies, xml ) | Need Help?? |
Well the regex did do the job in .NET (using $1$3 as replacement) on lists of the indicated type, like:
That is: "42,15,42,173,42" will be reduced to "15,173", which was basically what I wanted. And yes, "before,42XX,after" will be reduced to "beforeXX,after", but that was not the kind of data I needed to manipulate in this case. You can try out .NET regexes by installing the runtime plus a tool like RegexDesigner. Update And you're right: the regex by reasonablekeith above does the same, but will leave "before,42XX,after" intact (if that's what you want); His regex is shorter tho', and could be preferred for that reason, -- but it is not forgiving with resp. to whitespace around the numbers, ie. "23,42 ,45, 56,42" will be reduced to "23,42 ,45, 56". Best regards, Allan Dystrup
In Section
Seekers of Perl Wisdom
|
|