Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: How can I extract part of a string after a specific character

by Abigail-II (Bishop)
on Jul 11, 2002 at 09:57 UTC ( #180982=note: print w/replies, xml ) Need Help??


in reply to Re: How can I extract part of a string after a specific character
in thread How can I extract part of a string after a specific character

Both you and DamnDirtyApe have a .* preceeding the =. Why?
print $string =~ /=(.*)/
will do fine.

Abigail

Replies are listed 'Best First'.
Re: Re: How can I extract part of a string after a specific character
by Juerd (Abbot) on Jul 11, 2002 at 10:21 UTC

    will do fine.

    But not the same. Their versions grab everything after the last =, your version grabs evertyhing after the first one.
    I think your solution is better (and I'm sure it's a lot more efficient), but we can't know for sure without more information.

    $\ = "\n"; for ('title=foo' ,'title=foo=bar') { print "-> $_"; print /.*=(.*)/; print /=(.*)/; }

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

      Their versions grab everything after the last =, your version grabs evertyhing after the first one.
      Eh, no. Only *one* of their versions grabs everything after the last, the other grabs everything after the first. The problem however didn't specify what should happen if there are multiple = characters present.

      Abigail

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2023-03-24 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (60 votes). Check out past polls.

    Notices?