in reply to Simple RegEx Substring Extraction from a Delimited Text Record
which is surely a lot less readable or maintainable than/([^!]*)!([^!]*)!([^!]*)!([^!]*)!([^!]*)/
If you just want the numbers between INT= and the following !, you might do something more like:split /!/
Note that doesn't guarantee that the value will come from the second field, but neither did your example. If you wanted to do that, you might use:my $int = ($rec =~ /!INT=([0-9]+)!/);
One final note, you should be using print rather than printf in your examples.my $int = ($rec =~ /^[^!]*!INT=([0-9]+)!/);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Simple RegEx Substring Extraction from a Delimited Text Record
by Anonymous Monk on Mar 15, 2006 at 07:52 UTC |