Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

regexp: match anything but "/"

by ISAI student (Scribe)
on Jun 29, 2005 at 08:34 UTC ( #470923=perlquestion: print w/ replies, xml ) Need Help??
ISAI student has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I want to use regexp to match anything but the char "/". How do I do that? I've tried \/{0,0}, but I didn't get the results that I needed. -ISAI student

Comment on regexp: match anything but "/"
Re: regexp: match anything but "/"
by Zaxo (Archbishop) on Jun 29, 2005 at 08:43 UTC

    A negated character class will do it,

    if ( m![^/]! ) { # . . . }
    I used a different match delimiter so I didn't have to escape "/".

    After Compline,
    Zaxo

      This node was taken out by the NodeReaper on Wed Jun 29 19:52:50 2005 GMT
      Reason: [Nkuvu]: Delete: dupe of 471027 but without formatting

      For more information on this node visit: this

Re: regexp: match anything but "/"
by fmerges (Chaplain) on Jun 29, 2005 at 08:54 UTC

    Hi,

    Along with the first answer, take a look at regexp

    Salve, :-)

Re: regexp: match anything but "/"
by blazar (Canon) on Jun 29, 2005 at 09:18 UTC
    As a side note, it may well be that you really need to "match anything but the char "/"" but I can feel a slight XY smell here: what are you really after? Maybe there's a better logic...
Reaped: Re: regexp: match anything but "/"
by NodeReaper (Curate) on Jun 29, 2005 at 14:11 UTC
    This node was taken out by the NodeReaper on Thu Jun 30 01:30:42 2005 GMT
    Reason: [Arunbear]: Delete: dup of 471027

    For more information on this node visit: this

Re: regexp: match anything but "/"
by l.frankline (Hermit) on Jun 29, 2005 at 14:12 UTC
    the following statement can help u....

    if (m#[^\/]#)
    {
      # do something..
    }

    * Frank *

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://470923]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2015-07-03 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (49 votes), past polls