CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Regex failing

 



Jeff29
Novice

Dec 17, 2010, 2:39 PM

Post #1 of 2 (1983 views)
Regex failing Can't Post

INPUT:-
//tools/scripts/script_rev1.1.txt
//tools/scripts/files_data.txt

My below regeex fails when there is a "." (dot) in the PLF,how do I change it to match both the above examples?

Code
($line =~ /\/(\w+\.txt)/)



(This post was edited by Jeff29 on Dec 17, 2010, 2:39 PM)


Zhris
Enthusiast

Dec 17, 2010, 4:08 PM

Post #2 of 2 (1979 views)
Re: [Jeff29] Regex failing [In reply to] Can't Post

Use a character class instead, and include the ".". Probably a good idea to place an $ anchor on the end of the expression too.


Code
print "$1\n" if ($line =~ /\/([\w\.]+\.txt)$/);


Chris


(This post was edited by Zhris on Dec 17, 2010, 4:11 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives