Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Regex question

by olus (Curate)
on Jul 04, 2008 at 15:22 UTC ( [id://695584]=note: print w/replies, xml ) Need Help??


in reply to Regex question

There are a few issues with the code you showed us. You are reading the file line by line, so you do not want to check for points and levels the way you are doing, and write two lines for each line you read. Also, the match pattern must be between the first two slashes. I'd advise you to read the documentation again.

Nevertheless, I wrote a small script that I believe will get you on the right path. The foreach loop will act like your while (<FILEREAD>){ by iterating on the array @strings "line by line".

use strict; use warnings; my @strings = ( 'points: "_eglErdrm@}}vA|}vAihtB~}vAik{C|}vA}~mHnojBgzlBjy +[aktAoeAooo@_l`@wl^y{oA",', 'levels: "PKLMOKNLP",' ); foreach my $string (@strings) { $string =~ s/(points|levels):(.*),$/$2/; print $string."\n";; } # That outputs: "_eglErdrm@}}vA|}vAihtB~}vAik{C|}vA}~mHnojBgzlBjy[aktAoeAooo@_l`@wl^y +{oA" "PKLMOKNLP"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2024-03-28 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found