in reply to Get chars between 2 markers using regular expressions
$string="He0Hello~~He2World~~"; while ($string=~m/He\d(\w+)~~/g) { print "$1\n"; }
Update: actually, that's not quite correct, this will only work if your content consists of only alphanumeric or underscore characters. A more precise regex would be:
$string=~m/He\d([^~]+)~~/g
Which will capture all data and break on a single tilde sign. If you need to capture single tildes in your data as well you need
which is more accurate but slower (because it needs to look ahead).$string=~m/He\d(.+?)~~/g
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Get chars between 2 markers using regular expressions
by pKai (Priest) on Dec 06, 2005 at 14:00 UTC | |
by tirwhan (Abbot) on Dec 06, 2005 at 15:16 UTC | |
|
Re^2: Get chars between 2 markers using regular expressions
by Anonymous Monk on Dec 06, 2005 at 15:28 UTC | |
by Roy Johnson (Monsignor) on Dec 06, 2005 at 15:44 UTC |