Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

by SgtClueLs (Novice)
on Mar 07, 2002 at 22:33 UTC ( [id://150166]=note: print w/replies, xml ) Need Help??


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

Or the non cool way! Regular expression are for weenies! :)
$var = "one/two/three/four/five/six/"; split /\//, $var; pop; $var = $var . $_ foreach(@_);
  • Comment on Re: remove the part of the string that is after the second to last '/'
  • Download Code

Replies are listed 'Best First'.
Re: Re: remove the part of the string that is after the second to last '/'
by Juerd (Abbot) on Mar 08, 2002 at 09:10 UTC
    You weenie! You used a regular expression! :)

    I think I like this way of avoiding regexes better:
    substr($var, rindex($var, '/', length($var) - 2)) = '';

    ++ vs lbh qrpbqrq guvf hfvat n ge va Crey :)
    Nabgure bar vs lbh qvq fb jvgubhg ernqvat n znahny svefg.
    -- vs lbh hfrq OFQ pnrfne ;)
        - Whreq
    

Log In?
Username:
Password:

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

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





    Results (13 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.