I can't seem to find directions for controlling non-letter/number characters($#&@^!*()><?":{}) in regular expressions. Can someone enlighten me.
Example
A preg match expression that tests true for numbers only no special charcters no letters
/[^a-zA-Z]/
That locks out letters, how do you exclude the other characters?
Regex for controlling non-letter/number charcters
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
$only_numbers = (bool)preg_match( '#^ї0-9]+$#', $string );Okay
I get it. Once a noob always a noob.
Okay so the difference is you added the marks for begin of string "^" followed by the character class definition and end of string "$". With out the beginning and end the string will only test if the string has numbers.
Alright I think I'm getting the hang of this...
Thanks Feyd!
Okay so the difference is you added the marks for begin of string "^" followed by the character class definition and end of string "$". With out the beginning and end the string will only test if the string has numbers.
Alright I think I'm getting the hang of this...
Thanks Feyd!