JamesHunt Posted May 2, 2008 Share Posted May 2, 2008 I have two strings and I want to use eregi() to validate them, I have only used simple regular expressions before to validate strings and if I could get some help it would be much appreciated. I am making a form where the user submits content copied from another site, a game, it formats the submitted data into a string with no line breaks, and then splits it up into values to be submitted into a database, the splitting part is fine and so is the formatting part, as I said I need help validating the string before I split it. Examples of the two formatted strings: (Ore Name [a-zA-Z]) Ore<br />(Weight [0-9]) Isatons<br /><br />Asteroid Surface<br />(Content[Any Characters])<br />Asteroid Core (System Name [a-zA-Z])-(Sector Number [0-9, maximum 3 in length] )-(Grid Number [0-9, maximum 3 in length]) In the above the words inside brackets are variable. The content of the square brackets will inform you of what kind of characters you will find. I have tried the following for each string respectively, I know its not quite right at all.. eregi("[^A-Za-z]+\ Ore<br\ \/>[0-9]+\ Isatons<br\ \/><br\ \/>Asteroid\ Surface<br\ \/>*<br\ \/>Asteroid Core",$string1) eregi("[^a-z]+-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}",$string2) Once again I hope this all makes sense, I'm finding it hard to describe my problem. Cheers. Link to comment https://forums.phpfreaks.com/topic/103835-validation-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.