Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Return string that starts and ends with specific characters

by Eily (Monsignor)
on Jun 02, 2016 at 16:56 UTC ( [id://1164786]=note: print w/replies, xml ) Need Help??


in reply to Re: Return string that starts and ends with specific characters
in thread Return string that starts and ends with specific characters

The previous one works not only with multiple 'f's but also with multiple 'j's, this one will always match up to the rightmost 'j'.

  • Comment on Re^2: Return string that starts and ends with specific characters

Replies are listed 'Best First'.
Re^3: Return string that starts and ends with specific characters
by Anonymous Monk on Jun 02, 2016 at 16:58 UTC

    Yep. I was not sure what his actual requirements were, so I showed both.

Re^3: Return string that starts and ends with specific characters
by gilthoniel (Novice) on Jun 02, 2016 at 17:24 UTC
    Thanks this is great! How would I get it to print only to the leftmost j?
      to clarify, I want it to start at any available "f", but end at only the first "j" after that "f". Thanks
        #!/usr/bin/perl # http://perlmonks.org/?node_id=1164776 use strict; use warnings; print "$1\n" while 'asdfgfhjkljjj' =~ /(?=(f.*?j))/g

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-23 17:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found