-3

Possible Duplicate:
Converting ereg expressions to preg

http://www.google.co.in/aclk?sa=L&ai=C_jFQq_

http://www.google.co.in/aclk?sa=l&ai=CKKCUg

The highlighted part is common in my url.

My Regex

 if (preg_match('google.com/aclk\?sa\=L\&ai/i', $url))

Is this regex correct? I want to match my regex to my url.

Community
  • 1
  • 1
Thomas Cox
  • 309
  • 4
  • 12

2 Answers2

0

You've forgotten the delimiters:

if (preg_match('#google.com/aclk\?sa\=L\&ai/i#', $url))
                ^--                          ^--

Traditionally they're /, but since you're working on a URL, this is a case where it makes sense to use a different character, and I've chose # in this case.

It's unclear if that last /i is an actual delimiter and the case-insensitve flag, so I've left that in place as part of the pattern.

Marc B
  • 356,200
  • 43
  • 426
  • 500
0

Delimiter must not be alphanumeric or backslash, that is your error.

Oscar Jara
  • 14,129
  • 10
  • 62
  • 94