Why am I getting this regexp error? 
Author Message
 Why am I getting this regexp error?

I am writing a perl script, and I got this error:

</: unmatched () in regexp at /home/chfwahoo/bin/webspell line 140.

Line 140 is

$newfile =~ /<$match>$after$/s;

I've never gotten an error like this before, and I can't find any help anywhere else.  I am manipulating an html file if that
helps at all.  Any help on why I am getting this error would be greatly appreciated.  Thanx

-Chris

--
*--------------/\--------------===--------------/\--------------*
"How is ED-U-CA-TION supposed to make me feel smarter?"
                                               -Homer J. Simpson
Christopher D. Bain            Miami University, Oxford, OH


*--------------\/--------------===--------------\/--------------*



Sun, 24 Sep 2000 03:00:00 GMT  
 Why am I getting this regexp error?

             [posted and mailed to cited author]

Quote:
> I am writing a perl script, and I got this error:
> </: unmatched () in regexp at /home/chfwahoo/bin/webspell line 140.
> Line 140 is
> $newfile =~ /<$match>$after$/s;

It looks like there are some regex metacharacters in either or both of
$match and $after when that match is performed.  You'll want to use
the quotemeta operator, typically spelled in its doublequotish form,
like so:

   /<\Q$match\E>\Q$after\E$/s;

Your code sample raises a question: Why are you throwing away the
result of that match?  Are you using the $& variable, or its
mischievous twin brothers $` and $' ?

--



Mon, 25 Sep 2000 03:00:00 GMT  
 Why am I getting this regexp error?

Quote:

> I am writing a perl script, and I got this error:

> </: unmatched () in regexp at /home/chfwahoo/bin/webspell line 140.

> Line 140 is

> $newfile =~ /<$match>$after$/s;

i think you need to look into the values of $match and $after. it is
likely that one of these contains some parenthetical weirdness.
remember that the characters returned from the interpolation are used
in forming the regex. \Q (quotemeta) should be useful here.

cheers,

dan boorstein



Mon, 25 Sep 2000 03:00:00 GMT  
 Why am I getting this regexp error?

[posted and mailed]

Quote:

> I am writing a perl script, and I got this error:

> </: unmatched () in regexp at /home/chfwahoo/bin/webspell line 140.

> Line 140 is

> $newfile =~ /<$match>$after$/s;

After interpolating the values of $match and $after, your regex contains more
open parens than close parens (or vice versa).

If the values of $match and $after are meant to be literal strings in the
regex, try this, which will put a backslash before non-word characters in the
values of $match and $after.

$newfile =~ /<\Q$match\E>\Q$after\E$/s;

If $match and $after are meant to use regex metacharacters, count your parens
and make sure you match all the open and close parens.

--


    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."



Mon, 25 Sep 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Why am I getting an error with @_ ?

2. Why am I getting an undefined subroutine error?

3. FAQ 4.1 Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?

4. FAQ 4.1 Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?

5. FAQ 4.1 Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?

6. FAQ 4.1 Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?

7. FAQ: Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?

8. FAQ: Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?

9. FAQ: Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?

10. FAQ: Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?

11. FAQ: Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?

12. FAQ: Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?

 

 
Powered by phpBB® Forum Software