Solved

Regular expression help please

Posted on 2007-04-01
6
194 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
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Split wordpress loop 35 56
MVC - procedural PHP 10 35
selector:validator cookies 4 30
jQuery Toggle & Anchor Links 5 43
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…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

860 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