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,553
  • 8
  • 36
  • 62

2 Answers2

0

The last slash should be escaped

krampstudio
  • 3,519
  • 2
  • 43
  • 63
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
  • 741,623
  • 53
  • 500
  • 612