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

Re: Perl regular expression

by JavaFan (Canon)
on Apr 30, 2012 at 16:06 UTC ( #968106=note: print w/ replies, xml ) Need Help??


in reply to Perl regular expression

A couple of ways:

$str =~ s/589HC-CG26G-133578.*/589HC-CG26G-133578/; $str =~ s/589HC-CG26G-133578\K.*//; $str =~ s/(589HC-CG26G-133578).*/$1/; ($str) = $str =~ /(.*589HC-CG26G-133578)/; ($str) = $str =~ /.*589HC-CG26G-133578/g; $str = substr($str, 0, index($str, "589HC-CG26G-133578") + length("589 +HC-CG26G-133578")); substr($str, index($str, "589HC-CG26G-133578") + length("589HC-CG26G-1 +33578"), -1) = ""; $str = join "", (split /(589HC-CG26G-133578)/, $str)[0, 1];


Comment on Re: Perl regular expression
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2015-07-03 18:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (55 votes), past polls