Solved

PHP/REGEX: Match cannot be xw5f3kgx2nz

Posted on 2011-02-13
4
213 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 100 total points
ID: 34883916
You can just strip it from $x.

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

Assisted Solution

by:Ray Paseur
Ray Paseur earned 50 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 74

Accepted Solution

by:
käµfm³d   👽 earned 350 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 108

Expert Comment

by:Ray Paseur
ID: 34887952
@kaufmed

;-)

~Ray
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now