SPUG: RE / Split Question
C.J. Collier
cjcollier at colliertech.org
Wed Jul 30 20:18:52 CDT 2003
On Wed, 2003-07-30 at 16:54, Orr, Chuck (NOC) wrote:
> Hello All,
>
> Please help with the following dilemma:
>
> I am being given a glob of data from a web page that I need to
> fix with perl. It comes in as $blob looking like this:
>
> 425 501 sttlwa01t 425 712 sttlwa01t tacwa02t 425 337 tacwa02t ...
> I need to break this up so the word characters associated with the
> numbers stay with their numbers. Ideally, I would have an array like
> this:
>
> 425 501 sttlwa01t
> 425 712 sttlwa01t tacwa02t
> 425 337 tacwa02t
$ perl -e '$blob = "425 501 sttlwa01t 425 712 sttlwa01t tacwa02t 425 337
tacwa02t"; @matches = $blob =~ /(\d+ \d+(?: \D[\w\d]+)+)/g;
print(join("\n", @matches), "\n");'
425 501 sttlwa01t
425 712 sttlwa01t tacwa02t
425 337 tacwa02t
Ha. Please, someone make it look prettier.
C.J.
More information about the spug-list
mailing list