in reply to Capturing text between literal string delimiters (was: Regular expressions)
That code does the trick, although you may want to make it more generic if you're working on more complex strings. Also checkout using split() if possible.use Data::Dumper; my $string = "sp Hello there sp \n Hey hey sp How are you? sp"; my @result = $string =~ m< [ ]? # optional space sp # literal 'sp' [ ]? # optional space (.*?) # non-greedy capture [ ]? # optional space sp # literal 'sp' [ ]? # optional space >xg; print Dumper(\@result); __output__ $VAR1 = [ 'Hello there', 'How are you?' ];
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regular expressions
by aersoy (Scribe) on Jun 24, 2002 at 13:05 UTC | |
by broquaint (Abbot) on Jun 24, 2002 at 13:21 UTC | |
by aersoy (Scribe) on Jun 24, 2002 at 13:48 UTC | |
|
Re: Re: Regular expressions
by kidd (Curate) on Jun 24, 2002 at 12:53 UTC |