corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » More PHP RegEx


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author More PHP RegEx
ed
Member

Registered: 10th Sep 03
User status: Offline
23rd Sep 10 at 13:17   View User's Profile U2U Member Reply With Quote

Are you allowed to do something like this (i.e. use a function as your replace string)?

$content=preg_replace('/cms\:\/\/video\.(qvga|vga|hd)\.([0-9]*)/',videoPlayer($2),$content);

I can't seem to get it to work...
Laney
Member

Registered: 6th May 03
Location: Leeds
User status: Offline
23rd Sep 10 at 15:32   View User's Profile U2U Member Reply With Quote

$2 isn't gonna work is it?
ed
Member

Registered: 10th Sep 03
User status: Offline
23rd Sep 10 at 15:40   View User's Profile U2U Member Reply With Quote

Been having a bit of a search around and you are meant to use the e modifier like so:

$content=preg_replace('/cms\:\/\/video\.(qvga|vga|hd)\.([0-9]*)/e',"videoPlayer('\\2')",$content);

Which does the job
ed
Member

Registered: 10th Sep 03
User status: Offline
23rd Sep 10 at 15:41   View User's Profile U2U Member Reply With Quote

(By turning cms://video.qvga.86 into the right flavour of video embed code (Flash at the moment ))

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
PHP Coding - Contact Form "IF" Statements liamC Geek Day 6 182
1st Sep 09 at 13:08
by liamC
 
PHP Regex Geeks? ed Geek Day 7 230
25th Sep 09 at 22:40
by Tim
 
PHP RegEx (Regular Expressions) Dom Geek Day 3 119
14th May 10 at 12:50
by ed
 
MySQL RegEx ed Geek Day 11 258
12th Aug 10 at 22:26
by ed
 

Corsa Sport » Message Board » Off Day » Geek Day » More PHP RegEx 29 database queries in 0.0157049 seconds