Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Help with parsing a string

by moritz (Cardinal)
on Jul 22, 2008 at 21:05 UTC ( [id://699428]=note: print w/replies, xml ) Need Help??


in reply to Help with parsing a string

It seems that you're just trying to remove all whitespaces:
s/\s+//g;

Of course that doesn't verify your data, so you could use split instead (untested):

OUTER: while (<>){ chomp; my @items = split m/\s/; for my $i (@items) { last OUTER unless $i =~ m/^[a-f\d]{2}$/; } print join '', @items; }

Replies are listed 'Best First'.
Re^2: Help with parsing a string
by pc88mxer (Vicar) on Jul 22, 2008 at 21:31 UTC
    If you lines contain other text besides the hex numbers, you can restrict the space removal to just between the hex numbers with:
    $line =~ s{\b([a-f\d]{2})\s+(?=[a-f\d]{2}\b)}{$1}gi;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://699428]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2024-04-23 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found