• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

Regular expression help :-)

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
nybble05
Asked:
nybble05
  • 2
  • 2
1 Solution
 
rjkimbleCommented:
For 1:

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

You're not really going to be able to parse XML data using regular expressions.
0
 
nybble05Author Commented:
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
 
rjkimbleCommented:
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
 
gregoryyoungCommented:
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
 
nybble05Author Commented:
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now