-1

I'm trying to create an replacement which remove everything what is not between "http://" and ".flv".

Here is my code:

preg_replace('"http://(.*?).f;v"', '', $code);

but it doesn't work. Anyone can help me?

Thanks.

Newester
  • 1,457
  • 2
  • 14
  • 26
  • Also this will remove everything that starts with http:// and ends with flv and you wrote "not between". You need to escape dot before flv too (\.flv). As @Rizier123 mentioned, your delimiters are wrong. And why don't just preg_match_all to this pattern and collect matching values? You can implode them if you need them in one string. – BlindingLight Mar 30 '15 at 14:04
  • The delimiters are fine. – jeroen Mar 30 '15 at 14:27

2 Answers2

1

remove everything what is not between "http://" and ".flv"

http://example.com/path/test.flv?param=1 --> example.com/path/test

BTW, you have a typo in f;v, and your delimiters may cause problems. Replace

preg_replace('"http://(.*?).f;v"', '', $code);

with

preg_replace('/http\:\/\/(.*?)\.flv.*/i', '$1', $code);
Drakes
  • 23,254
  • 3
  • 51
  • 94
0

Are you looking for something like this:

http:\/\/(.*?).flv

http://www.somesite.com/ac.flv

DEMO: https://regex101.com/r/tN2tG2/1

Keep Coding
  • 636
  • 9
  • 26