in reply to Splitting a string based on a regex
Um, if you have a regular expression and want to split a string based on that regular expression, that's what split does. Am I missing something?
update: here's some code (untested):
# assuming you've got the RE in $re ... my @parts = split /(?=$re)/, $string;
I used a zero-width look-ahead so that the text is split just before the part that matches as that seems to be your desire.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Splitting a string based on a regex
by Anonymous Monk on Feb 06, 2006 at 14:39 UTC | |
by duff (Parson) on Feb 06, 2006 at 15:37 UTC | |
by Anonymous Monk on Feb 07, 2006 at 09:00 UTC | |
by Anonymous Monk on Feb 06, 2006 at 15:33 UTC |