-3

I've seen similar questions on here, but I don't think any of them helped with this.

I've inherited a site from someone who used an older version of PHP and specifically the ereg function. Their original reg ex was:

$regex = "[ ]+[0-9]+) ( [a-zA-Z]+)[ ]+Crimson[ ]+([0-9]+)[ ]+[0-9]+[ ]+[0-9]+[ ]+[0-9]+[ ]+([0-9]+)[ ]+[0-9]+";

I've read that you need to start and end with a delimiter, so i've updated it to:

$regex = "/[ ]+[0-9]+) (    [a-zA-Z]+)[ ]+Crimson[ ]+([0-9]+)[ ]+[0-9]+[ ]+[0-9]+[ ]+[0-9]+[ ]+([0-9]+)[ ]+[0-9]+/";

But I am still getting this error:

Warning: preg_match(): Compilation failed: unmatched parentheses at offset 10

I don't see any special characters in the expression, so I am unsure as to what else I need to escape. Any ideas?

Nick
  • 1,262
  • 1
  • 17
  • 32

2 Answers2

2

You've got ) near the beginning of your regexp, but you didn't open that. If it's literal, add backslash before it.

/[ ]+[0-9]+)

to

/[ ]+[0-9]+\)

If not, open it first.

Elon Than
  • 9,603
  • 4
  • 27
  • 37
  • Ahh that was it. The ) was actually suppose to be literal so I escaped it. Thank you very much for pointing this out. That was definitely going to be one of those that I spend 4 hours looking for and only find at the very last moment! – Nick Oct 22 '13 at 18:29
1

At position 10 you have an closing ) , without an opening (

Peter van der Wal
  • 11,141
  • 2
  • 21
  • 29