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:
need help matching \d+

 



imillard
Deleted

Jan 22, 2001, 10:03 AM

Post #1 of 4 (1435 views)
need help matching \d+ Can't Post

I am trying to match with \d+. Here is a line that I am having trouble matching.

include => ["^http://jama.ama-assn.org/issues/v28 [4 - 9]n\\\d+/toc\\.htm"]

Here are some example matching page URL's:
http://jama.ama-assn.org/issues/v285n3/toc.html
http://jama.ama-assn.org/issues/v285n2/toc.html

The error message I get is:
Unrecognized escape \d passed through at ...(everyline I used the \d+ in my script)

Any suggestions?



sleuth
Enthusiast

Jan 22, 2001, 12:25 PM

Post #2 of 4 (1432 views)
Re: need help matching \d+ [In reply to] Can't Post

 
What version of perl are you on, and give a few lines of code where you use \d

Tony



imillard
Deleted

Jan 22, 2001, 12:35 PM

Post #3 of 4 (1431 views)
Re: need help matching \d+ [In reply to] Can't Post

I am using Perl 5.

#! /usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;

%prefs = (

jama => { source => "Journal of the American Medical Association",
urls => ["http://jama.ama-assn.org/pi/index.html"],
include => ["^http://jama.ama-assn.org/issues/v28[4-9]n\\\d+/toc\\.htm",
"^http://jama.ama-assn.org/issues/v28[4-9]n\\\d+/ffull",
"^http://jama.ama-assn.org/issues/v28[4-9]n\\\d+/abs"],
TitleSub => sub {
my ($c, $url) = @_;
return $1 if ( $c =~ /<meta name="DOCTITLE" content="(.*?)">/si );
},
xreg => ["\\.pdf","/v284n[1-9]/","/v284n10/","/rfull/"],
depth => 3,
index => 0,},

);

Here is an example of some code.



sleuth
Enthusiast

Jan 22, 2001, 6:42 PM

Post #4 of 4 (1429 views)
Re: need help matching \d+ [In reply to] Can't Post

 
I think the preceding \\ is messing with it, perl 5 is ok to go for \d. Tell me if you still get an error if you run this program.

#!/usr/bin/perl
print "Content-type: text/html\n\n";
$scalar = "1234568This is text654894";
$scalar =~ s!\d+!!g;
print "$scalar";

If the out put is just "this is text" then \d is working fine.

The way you explained it made me think it happends all the time so I was looking for regexes like that one up there in your code to see if it was used correctly.

I think if you modify your code a little to separate \d+ from \\ it could solve that problem. Second thing I'm thinking is \d+ isn't used like that and only in regexes and matching.

What exactly are you trying to do anyway?

Tony


 
 


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

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