Solved

Regular expression help :-)

Posted on 2004-08-02
7
192 Views
Last Modified: 2010-04-06
Ok, I need 2 regex strings..... (to be used with PHP)

1. Check string to make sure it does not begin with '.' and that it has .gif/.GIF (/i?) at the end
2. To get the data in XML (Unless you have a better idea?) eg. <option1>Foobar</option1> would return Foobar.
0
Comment
Question by:nybble05
[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
  • 2
  • 2
7 Comments
 
LVL 9

Expert Comment

by:rjkimble
ID: 11692870
For 1:

^[^.].*\.gif$(?i)

You're not really going to be able to parse XML data using regular expressions.
0
 
LVL 2

Author Comment

by:nybble05
ID: 11692911
So... hmm, I thought that was how I did it before, but then I lost all my files :-(
Any ideas on how to work with XML?
0
 
LVL 9

Expert Comment

by:rjkimble
ID: 11693718
I'm not really a PHP guy. I did a little googling and found a number of articles on parsing XML with PHP, but you should get a better answer from somebody who's familiar with it. I just answered the regular expression part -- that's the stuff I'm familiar with.
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 125 total points
ID: 11699902
i would tke a look here http://us3.php.net/xml

the problem with using regexps on XML is that they also nest....

<Options>
<Option1> foobar</Option1>
</Options>

you instead really need a stack/tree based parser to handle some of the situations that can come up.
0
 
LVL 2

Author Comment

by:nybble05
ID: 12109171
I forgot I opened this but I got an answer elsewhere. I it is ok you gave him the points but please share them with  rjkimble as his answer was EXACTLY what I wanted. While the other guy gave me links to something else I did not ask for. Sorry.
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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

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