im a novice in php regEx...plz help me preg_match will return true if given link is like these: http://www.mydomain.com/path/file.php?dataid=[B]x92DFt[/B]_maradonna-hand_of_god-gallery&hr=1 www.mydomain.com/path/file.php?dataid=[B]x92DFt[/B]_maradonna-hand_of_god-gallery&hr=1 mydomain.com/path/file.php?dataid=[B]x92DFt[/B]_maradonna-hand_of_god-gallery&hr=1 Code (markup): well i mean it will not care if http://www there or not 2nd-> it will retrieve the id which is mixed with data name but they r separated by an underscore ( _ ) but plz notice, there cud be underscore inside the data name. another important thing is, id's length is unknown but it never contain sign but only A-Z a-z 0-9 for example: x92DFt_maradonna-hand_of_god-gallery highlighted one is id & its separated by an underscore although there r underscore in the data name (maradonna-hand_of_god-gallery) help me plz
Instead of using regex, how about split it into array like below(the code not been tested though): And thanks unigogo for the link(that gonna help for the regex tester) As for the pattern, I believe it should be something like "/(\w+)_/" but forgive me if Im wrong
how do u declare $ptn = "/x92DFt([\w_-]+)/"; id is variable...totally unknown if its known why shud i retrieve it & tnx for the link....not checked yet...will check it later
trying & trying & failed ok. can anyone plz give me a preg_match() code of this link, so i'll understand how it works $url = 'http://www.dailymotion.com/video/xb3bcy_los-angeles-a-marijuana-smokers-hea_news'; $pattern = ???? // i need this preg_match($pattern, $url, $match); echo $match[1]; // it will return only: xb3bcy PHP: yes...i want it only retrieve xb3bcy from the link
just use the regex coach, it's excellent for training you. assuming the string is always consistent you could use: $pattern = 'http://www.dailymotion.com/video/(.*?)_'; PHP: or if you know that the string you're looking for will always be 6 chars long (inc. digits) then $pattern = 'http://www.dailymotion.com/video/(.{6})'; PHP: and you don't even need the underscore (_) in that case!
just a quick question [a-z0-9] means what?? Alphabetic & numeric only?? or it includes special sign like @#$%&*-_=+ if not what includes those sign & Alphabetic & numeric...i mean all