Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: pattern matching

by perlinux (Deacon)
on May 04, 2004 at 11:36 UTC ( [id://350293]=note: print w/replies, xml ) Need Help??


in reply to pattern matching

Try this simple script for your line:
#!/usr/bin/perl -w use strict; my $line = "0010 0010 text // text // JOHN DOE"; chomp $line; if ($line =~ /^(0010 ){2}(.*\/\/ ){2}(.*)$/) { my $name = $3; }
UPDATE:
Also:
my $name = "0010 0010 text // text // JOHN DOE"; chomp($name); + $name =~ s/^(0010 ){2}(.*\/\/ ){2}(.*)$/$3/i; print $name;

Replies are listed 'Best First'.
Re: Re: pattern matching
by Anomynous Monk (Scribe) on May 04, 2004 at 18:18 UTC
    For the curious, perl reoptimizes (0010 ){2} back into "0010 0010 " when looking for possible places to match (even without the ^).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-18 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found