Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unmatched () in regexp

Status
Not open for further replies.

Graziella

Programmer
Jul 8, 2004
38
AT
Hello,

this is something that I still do not know how to avoid.

Assume I have some statement like this one
if ($eng =~ /$chunk/) {
print "$eng\n";
}

If $chunk is something like "word (" then I get an error message like unmatched () in regexp
But I want to be able to search for "word (" (yes, with that open parenthesis ) in $eng. How to I go about checking whether the entire $chunk is contained in $eng ?

Hope you can help.

Grazia
 
think i've understood you...

Code:
[b]#!/usr/bin/perl[/b]

$chunk = '"word ("';

$eng = 'will this match the "word (" in this sentence';

if ($eng =~ /[red][b]\Q[/b][/red]$chunk/i) {
  print "$eng\n";
} else {
  print "no match\n"
}

it does kick up an error without the [red]\Q[/red]


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top