Solved

Regular expression help please

Posted on 2007-04-01
6
197 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:Cornelia Yoder
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
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.
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.

726 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