Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP/REGEX: Match cannot be xw5f3kgx2nz

Posted on 2011-02-13
4
Medium Priority
?
243 Views
Last Modified: 2012-05-11
How can this be modified so that xw5f3kgx2nz is never a match?
preg_match_all("/\/watch\?v=(.*?)[&\"]/i", $x, $y);

Open in new window

0
Comment
Question by:hankknight
  • 2
4 Comments
 
LVL 8

Assisted Solution

by:rationalboss
rationalboss earned 400 total points
ID: 34883916
You can just strip it from $x.

$x = str_replace('xw5f3kgx2nz','',$x);
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 34884198
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
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1400 total points
ID: 34887790
I *think* this is what you are asking:
preg_match_all("/\/watch\?v=(?!xw5f3kgx2nz)(.*?)[&\"]/i", $x, $y);

Open in new window

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 34887952
@kaufmed

;-)

~Ray
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question