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

Re: remove the part of the string that is after the second to last '/'

by ajwans (Scribe)
on Mar 07, 2002 at 21:46 UTC ( [id://150145]=note: print w/replies, xml ) Need Help??


in reply to remove the part of the string that is after the second to last '/'

How about

$string =~ s!^(.*/).*?/$!$1!;

Guess I just prefer non-greedy matching to negated character classes.

1. dude, what does mine say?
2. "sweet", what about mine?
3. "dude", what does mine say?
4. GOTO 2
  • Comment on Re: remove the part of the string that is after the second to last '/'
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-09-14 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.