Hi.
My problem regards the use of preg_match... I send a variable to a function and then I use preg_match on it.
There are 3 different valid expressions I want to check for.. These are:
xxxxx...-xx...-x...
xxxx-xx-xx-x...
xxxx-xx-xxxx-xx-xx-x...
where "x" is a digit [0-9] and "..." is more digits. The numeric sequences are seperated by "-".
All other expressions should result in an error message.
I know that this can be done with preg_match, but not how... Anyone?
Regards tores
preg_match
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
is x required digits, and the dots optional?if sountested
Code: Select all
preg_match('#^([0-9]{5,8}-[0-9]{2,5}-[0-9]{1,4}|[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{1,4}|[0-9]{4}-[0-9]{2}-[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{1,4})$#',$string)