Solved

Regular expression help please

Posted on 2007-04-01
6
191 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
Comment Utility
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
Comment Utility
preg_match_all('/<start_snip>.*?<end_snip>/is',$str,$match);
0
 
LVL 29

Assisted Solution

by:TeRReF
TeRReF earned 250 total points
Comment Utility
SHouldn't it be:

preg_match_all('/<start_snip>(.*?)<end_snip>/is',$str,$match);
print_r($match[1]);
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 11

Expert Comment

by:JamesCssl
Comment Utility
I believe you are correct, TeRReF.
0
 

Author Comment

by:St_Aug_Beach_Bum
Comment Utility
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
Comment Utility
I'm actually surprised it worked without the parenthesis.  I would split up the points.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now