php – regex ignoring line breaks
-
I want to replace youtube urls with an iframe. Therefore I use a regex which I’ve copied from different websites. It takes video ids from youtube urls.
It doesn’t work perfect. If there is a line break it doesn’t take the entire video id. Also it doesn’t take &feature=share from the url.
Please help me to find a solution for this issue. Thank you.
For example
Input:http://www.youtube.com/attribution_link?a=_NDwn20sMog&u=/watch?v=zl-GC1 6vBm4&feature=shareRegex:
/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|attribution_link\?a=.+?watch.+?v(?:%|=)|watch\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11})/iOutput:
Array ( [0] => zl-GC1 ) Array ( [0] => http://www.youtube.com/attribution_link?a=_NDwn20sMog&u=/watch?v=zl-GC1 )
The topic ‘php – regex ignoring line breaks’ is closed to new replies.