in reply to Regular Expression Builder
But i dont think this will scale very well... (and probably has subtle problems anyway)my $string="123 abcdef"; $string=~s{(\d+)|(\w+)|(\s+)} { defined($1) ? '\\d{'.length($1).'}' : defined($2) ? '\\w{'.length($2).'}' : '\\s{'.length($3).'}' }ge; print $string; __END__ \d{3}\s{1}\w{6}
Yves / DeMerphq
---
Software Engineering is Programming when you can't. -- E. W. Dijkstra (RIP)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regular Expression Builder
by Anonymous Monk on Aug 30, 2002 at 17:05 UTC | |
by demerphq (Chancellor) on Aug 30, 2002 at 17:18 UTC | |
by Anonymous Monk on Aug 30, 2002 at 17:29 UTC | |
by Dog and Pony (Priest) on Sep 02, 2002 at 20:11 UTC |