Solved

Regular expression help :-)

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

757 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

22 Experts available now in Live!

Get 1:1 Help Now