Solved

PHP/REGEX: Match cannot be xw5f3kgx2nz

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

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

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 75

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 110

Expert Comment

by:Ray Paseur
ID: 34887952
@kaufmed

;-)

~Ray
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

615 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