Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: extract the value before a particualr string

by space_monk (Chaplain)
on Sep 05, 2013 at 10:12 UTC ( #1052536=note: print w/ replies, xml ) Need Help??


in reply to extract the value before a particualr string

If you don't like split, try regexes instead. Something like ...

if (/(\d+)\/total$/) { print "$1\n"; }
If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)


Comment on Re: extract the value before a particualr string
Download Code
Re^2: extract the value before a particualr string
by nanban (Initiate) on Sep 05, 2013 at 10:23 UTC
    Thanks for the reply... Can we implement it using split? i am pretty new to perl...
Re^2: extract the value before a particualr string
by nanban (Initiate) on Sep 05, 2013 at 10:29 UTC
    will it be possible to use split???
      nanban,
      will it be possible to use split???

      The first argument to split is a regular expression so it is really the difference between using capturing parens in a regular expression or using a regular expression to break the string into pieces but they are both regular expression solutions.

      Cheers - L~R

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2014-09-16 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (33 votes), past polls