homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Interesting Regular Expression

 5:08 pm on Nov 15, 2007 (gmt 0)

Hello, I am stuck trying to come up with a regular expression to validate, and then grab out into an array of the following data structure. I did not build this data structure but I am trying to work with it. Any ideas?

Label "option1" "option2" "option3"

The Label is the first element of this and is not enclosed in quotes, the individual options however are enclosed in quotes.

So i need to validate that the user entered the data in this format with unlimited "options"

The second part would be to at a later time get this data and put it into an array with the "Label" as the [0] element of an array to make an array like this.

$array[0] == "Label"
$array[1] == "option1"
$array[2] == "option2"
$array[3] == "option3"

Thanks alot, and any ideas would really help tons!



 5:58 pm on Nov 15, 2007 (gmt 0)

Nevermind, if figured it out. thanks.

^([a-z])+ (\"([a-z])+\" )+$


 9:37 pm on Nov 15, 2007 (gmt 0)

^([a-z])+ (\"([a-z])+\" )+$
will not match the Label "option1" etc that you posted.
As you have only specified lower case letters in your classes (so Label wont match), and there is no digits in your quoted part (so option1 wont match).

$pattern = '%([a-z]+) ("[a-z]+\d"...space in here...?)+%i'; will match what you put up. Stupid forum removing spaces...

Dont know if your problem is sorted as you are using different data to the example, or if you havent tested your work. So this may, or may not help you ;)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved