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

Re: Regular Expression Assistance

by moxliukas (Curate)
on Jun 10, 2002 at 12:47 UTC ( [id://173098]=note: print w/replies, xml ) Need Help??


in reply to Regular Expression Assistance

Well, a quick solution to this could be

$_ =~ /(\/home\/monks\/thanksforhelping\d+\.ext)/

However there are some points that I would like to make:

  • This will work only if the scalar contains the path you are searching
  • If there are two or more paths like this i a scalar, this will match only the first one
  • I am not an expert in regexp either, so always take my advice with a grain of salt ;)

Replies are listed 'Best First'.
Re: Re: Regular Expression Assistance
by Anonymous Monk on Jun 10, 2002 at 12:55 UTC
    This is what I thought it should look like. Unfortunately, when I tested it, I also got stuff that was on the same line as the path I wanted, but was not part of the path itself. For instance, I got:

    but you might try looking at /home/monks/thanksforhelping1234567890.ext for help

    Any suggestions on how to get rid of the excess stuff?

      I don't really know what is happening at your end, but this seems

      $_ = "but you might try looking at /home/monks/thanksforhelping1234567 +890.ext for help"; $_ =~ /(\/home\/monks\/thanksforhelping\d+\.ext)/; print $1;

      to output:

      /home/monks/thanksforhelping1234567890.ext

      So check for typos... that could be your problem

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-18 19:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found