PHP/REGEX: Match cannot be xw5f3kgx2nz

How can this be modified so that xw5f3kgx2nz is never a match?
preg_match_all("/\/watch\?v=(.*?)[&\"]/i", $x, $y);

Open in new window

LVL 16
hankknightAsked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor Commented:
I *think* this is what you are asking:
preg_match_all("/\/watch\?v=(?!xw5f3kgx2nz)(.*?)[&\"]/i", $x, $y);

Open in new window

0
 
rationalbossConnect With a Mentor Commented:
You can just strip it from $x.

$x = str_replace('xw5f3kgx2nz','',$x);
0
 
Ray PaseurConnect With a Mentor Commented:
Is xw5f3kgx2nz the only string you ever want to exclude?  If so, just test for it and skip the REGEX matching.  If not, please explain what the rules are for the strings that you want to exclude.  Thanks, ~Ray
0
 
Ray PaseurCommented:
@kaufmed

;-)

~Ray
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.