0

Possible Duplicate:
preg_match() Unknown modifier '[' help

I am trying to match this pattern

 $regex_pattern = '<td id="(\w+)" class="(\w+)">(\w+).com<\/td>';
 preg_match_all($regex_pattern, $result, $matches);
 print_r($matches);

But I am getting this error: Warning: preg_match_all(): Unknown modifier '(' in

What's wrong in my regex pattern?

Community
  • 1
  • 1
dextervip
  • 4,999
  • 16
  • 65
  • 93

1 Answers1

5

Add delimiters to your pattern

When using the PCRE functions, it is required that the pattern is enclosed by delimiters. A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character.

Often used delimiters are forward slashes (/), hash signs (#) and tildes (~).

 $regex_pattern = '/<td id="(\w+)" class="(\w+)">(\w+).com<\/td>/';
 preg_match_all($regex_pattern, $result, $matches);
 print_r($matches);
Mike B
  • 31,886
  • 13
  • 87
  • 111