Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP/REGEX: Match cannot be xw5f3kgx2nz

Posted on 2011-02-13
4
Medium Priority
?
235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

721 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