0

I am using preg_match function to my program like this

(preg_match('/^(f|ht)tps?\://', $this->sourceFilename))

But it shows a warning like this

Warning: preg_match() [function.preg-match]: Unknown modifier '/'

How can it modify? Please help me!!!

Vedant Terkar
  • 4,365
  • 5
  • 35
  • 60

2 Answers2

0

The last slash should be escaped

krampstudio
  • 3,231
  • 2
  • 40
  • 56
0

You need to escape the / inside the regexp:

preg_match('/^(f|ht)tps?:\//', $this->sourceFilename)

or use a different delimiter:

preg_match('#^(f|ht)tps?:/#', $this->sourceFilename)

BTW, you don't need to escape :.

Barmar
  • 669,327
  • 51
  • 454
  • 560