Solved

Regular expression help please

Posted on 2007-04-01
6
196 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
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

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!

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

734 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