Solved

Regular expression help :-)

Posted on 2004-08-02
7
189 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

920 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

15 Experts available now in Live!

Get 1:1 Help Now