REGEX prob for catching three ways of input
Posted: Fri Aug 22, 2008 2:37 am
Hi everyone this is my first post, and hope to be around for a long time here....
I have a problem where the user can input some text or numbers but only in three ways, any other way has to result in an error, I need this case insensitive and need it to Unicode for say Japanese characters etc.
If there is one match then I would like to display and error for the user to correct. If all is good, then I will explode the users input into an array by using a comma as the delimiter.
Here's what I have worked on...
Firstly
The examples of the three valid formats of input...
sometext
sometext,sometext
somenumber.somenumber sometext
Further examples
somenumber.somenumber sometext, sometext
sometext,somenumber.somenumber sometext
sometext, somenumber.somenumber sometext
I use http://www.lumadis.be/regex/test_regex.php for my testing, including testing on my test page to make sure.
The user's input come via a text box on a form. I run trim, strip tags and stripslahes first, then the regex
Secondly
My REGEX's...
Tried separating them and testing then combining them, but I can't get it to validate correctly
.
Characters need a limit of 60 on each entry but I have some other testing for that elsewhere.
I hope someone can help as I've spent a week at this trying to get it to work.
Thanks in advance for any replies.
I have a problem where the user can input some text or numbers but only in three ways, any other way has to result in an error, I need this case insensitive and need it to Unicode for say Japanese characters etc.
If there is one match then I would like to display and error for the user to correct. If all is good, then I will explode the users input into an array by using a comma as the delimiter.
Here's what I have worked on...
Firstly
The examples of the three valid formats of input...
sometext
sometext,sometext
somenumber.somenumber sometext
Further examples
somenumber.somenumber sometext, sometext
sometext,somenumber.somenumber sometext
sometext, somenumber.somenumber sometext
I use http://www.lumadis.be/regex/test_regex.php for my testing, including testing on my test page to make sure.
The user's input come via a text box on a form. I run trim, strip tags and stripslahes first, then the regex
Secondly
My REGEX's...
Tried separating them and testing then combining them, but I can't get it to validate correctly
Code: Select all
/[a-z-A-Z]+|[a-zA-Z]\,\s[a-zA-z]+|[1-9]\.[1-9]\s[a-zA-Z]+/iuCode: Select all
/[a-z-A-Z]+|[a-zA-Z]\,\s[a-zA-z]+|[1-9]\.[1-9]\s[a-zA-Z]+/Code: Select all
/^[^a-z-A-Z]+|^[a-zA-Z]\,\s[a-zA-z]+|^[1-9]\.[1-9]\s[a-zA-Z]+/iuI hope someone can help as I've spent a week at this trying to get it to work.
Thanks in advance for any replies.