Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Detecting whether forward slash is present in string

by zdog (Priest)
on Sep 13, 2004 at 21:54 UTC ( #390675=note: print w/replies, xml ) Need Help??


in reply to Detecting whether forward slash is present in string

Good ol' substitution regex:

# if ( substr( $string1, -1, 1 ) eq "/" ) # check for trailing slash. if ( $string1 =~ s|/\s*$|/| ) # even better { $string2 =~ s|^/||; # remove leading slash if it's present. }

Update: Added additional code to satisfy problem requirements more fully.

Zenon Zabinski | zdog | zdog@perlmonk.org

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://390675]
help
Chatterbox?
[Corion]: Hi jkva!
[Corion]: karlgoethevier: Oooh, that sounds interesting! ;)
[karlgoethebier]: btw, good morning
[Happy-the-monk]: karlgoethebier: have fun! Did some archery at the age of 14 or so.
[karlgoethebier]: Corion: It is, indeed.
[Happy-the-monk]: even more OT: received the complete series of Robin Hood/Robin of Sherwood 1984 on used dvds this morning :)
[Happy-the-monk]: (purely coincidental)
[jkva]: Corion Hey there :)
[Happy-the-monk]: Discipulus: are there any perl monks in Milano?
[Discipulus]: i the moment likely no

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-10-20 09:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (260 votes). Check out past polls.

    Notices?