Solved

Modification to the previous regular expression

Posted on 2009-07-14
5
261 Views
Last Modified: 2012-05-07
Hi Guys,

sorry to bother you again...

The previous regular expression worked like a charm but now, I want to exclude this specific string from it:
"{\pict\wmetafile8\picw6615\pich1852\picwgoal3750\picscalex150\pichgoal1050\picscaley150\sspicalign0 " followed by anithing and closed by "}"

So, I want to replace all the "{\pict" followed by anything and closed by "}" except if it is the block I don't want to replace

Can any of you help me on this one

Btw, any good regular expression book you could suggest ?

Regards

0
Comment
Question by:msd_informatique
  • 3
  • 2
5 Comments
 
LVL 3

Author Comment

by:msd_informatique
ID: 24855424
Btw, in case it's not clear, there is a link to the previous question...
http://www.experts-exchange.com/Programming/Languages/Regular_Expressions/Q_24561714.html
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 100 total points
ID: 24855478
Try this:

$toExclude = preg_quote('\wmetafile8\picw6615\pich1852\picwgoal3750\picscalex150\pichgoal1050\picscaley150\sspicalign0','/');
echo preg_replace("/\{\\\\pict(?!$toExclude).*?\\}/s", '', $s);
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 24855490
Sorry, I can't recommend a book - you might be best asking that as a separate question to get a better response.
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 24855498
But if you're not aware of the PCRE Cheat Sheet, it's well worth bookmarking - it's linked from here:
http://www.phpguru.org/article/pcre-cheat-sheet
0
 
LVL 3

Author Closing Comment

by:msd_informatique
ID: 31603550
Thanks that worked like a charm :)

Regards
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Number of hours between date in DB and now 8 21
Accessing specific element - DOM PHP HTML 8 35
Ajax and PHP 4 31
Add a loading gif while php runs server side 15 37
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

828 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