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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions:
need help matching \d+



Jan 22, 2001, 10:03 AM

Post #1 of 4 (2318 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 => ["^ [4 - 9]n\\\d+/toc\\.htm"]

Here are some example matching page URL's:

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

Any suggestions?


Jan 22, 2001, 12:25 PM

Post #2 of 4 (2315 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



Jan 22, 2001, 12:35 PM

Post #3 of 4 (2314 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 => [""],
include => ["^[4-9]n\\\d+/toc\\.htm",
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.


Jan 22, 2001, 6:42 PM

Post #4 of 4 (2312 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.

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?



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

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