Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Small replace regular exp help...pls

by SamCG (Hermit)
on Mar 09, 2006 at 22:29 UTC ( [id://535537]=note: print w/replies, xml ) Need Help??


in reply to Small replace regular exp help...pls



You might also try, especially if "Some Text 1:" isn't standardized and you don't actually want the word "Data":
$str= "Some text1 : Data Some Text2"; $str=~/:\s+Data\s(.+)\z/; $youwant=$1; ##$1 is the captured (.+) part print $youwant;
prints "Some Text2"

It's not technically a substitution, of course -- $str remains the same -- but if you wanted to you could just set $str to $youwant at the end (or even to $1 earlier). or you could:
$str= "Some text1 : Data Some Text2"; $str=~s/.+?:\s+Data\s(.+)\z/$1/; print $str;
to use the substitution operator.. .

update: I thought the "Some Text2" WAS the data, and the "Data" was a literal (I don't know, announcing that a bunch of data was to follow, or something. Dense of me, I guess). My suggestions could be modified, but it would depend on what "Data" contained.

update2: dani_cv_72 looks quite a bit like dani_cv_perl, who posed very similar questions.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-20 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found