-1

I want to run the following regex in PHP but I faced with the error that says:

preg_match() [function.preg-match]: No ending delimiter '^'

My Code:

if (preg_match("^(?!.*(l_name|f_name|m_name)).*$", $str)) {
   // Do sth 
}

Any ideas?

iSun
  • 1,714
  • 6
  • 28
  • 57
  • 1
    Add delimiteeeeeeeeeeeeeers ! For example `#` at the begin and the end :p – HamZa Jul 09 '13 at 09:31
  • @HamZa Added and error has been gone but the regex doesn't work, however it is work on JAVA! – iSun Jul 09 '13 at 09:33
  • 3
    @iSun To figure out why your regex doesn't work we need your `$str`, or else we haven't got a clue what's in the string. – h2ooooooo Jul 09 '13 at 09:34
  • [T-Regx](https://github.com/Danon/T-Regx) library can automatically add delimiters, so author's code would work. – Danon Oct 09 '18 at 13:50

1 Answers1

3

Try

if (preg_match("/^(?!.*(l_name|f_name|m_name)).*$/", $str)) {
   // Do sth    ^                                ^
}
h2ooooooo
  • 39,111
  • 8
  • 68
  • 102
Simon King
  • 453
  • 3
  • 9