Solved

Regular expression help :-)

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with Connection / Parameter: 4 21
Technology stack suggestions 4 67
SEO friendly way to have two domains on website 9 94
React or Angular? 6 81
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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.
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

820 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