Solved

Regular expression help please

Posted on 2007-04-01
6
195 Views
Last Modified: 2007-04-01
Arrgh, I chose a solution on my last question a little to quickly, didn't test it completely (though the question was answered well)

I have this:

preg_match_all('/<start_snip>[^<]*<end_snip>/',$str,$match);

I need it changed so that it delivers all the content in between the <start_snip> and <end_snip>, as it is above, it only delivers if numbers are in between, I need letters, numbers, commas, cash signs, periods, everything.   I don't know/understand reqular expression enough to do this myself, out of my league!  

I'm using php4.3.3 if that makes a difference here.

Thanks,         Chris  
0
Comment
Question by:St_Aug_Beach_Bum
[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
6 Comments
 
LVL 27

Expert Comment

by:yodercm
ID: 18833293
On your first question, you implied there might be several strings of start_snip, something, end_snip in each input.  Is that true?
0
 
LVL 11

Accepted Solution

by:
JamesCssl earned 250 total points
ID: 18833296
preg_match_all('/<start_snip>.*?<end_snip>/is',$str,$match);
0
 
LVL 29

Assisted Solution

by:TeRReF
TeRReF earned 250 total points
ID: 18833307
SHouldn't it be:

preg_match_all('/<start_snip>(.*?)<end_snip>/is',$str,$match);
print_r($match[1]);
0
Technology Partners: 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!

 
LVL 11

Expert Comment

by:JamesCssl
ID: 18833317
I believe you are correct, TeRReF.
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 18833830
Thank you both!

That works, actually, both ways work without any errors.  

Suggestions on how I should reward points on this?  Since both work but JamesCssl indicates TeRReF's is (more?) correct?
0
 
LVL 11

Expert Comment

by:JamesCssl
ID: 18833844
I'm actually surprised it worked without the parenthesis.  I would split up the points.
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

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

749 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