The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Simple regex question
I am getting a $value from a $_POST['value'] from a textbox
How can I make sure that only "digits" and "spaces" are allowed, and nothing else? eg 55 32 etc... but no 55-32 or abcd or [ or * or etc... |
#2
|
|||
|
|||
PHP Code:
|
#3
|
||||
|
||||
That will die on spaces. This should work.
PHP Code:
PHP Code:
|
#4
|
|||
|
|||
Both methods stop valid and invalid characters.
|
#5
|
||||
|
||||
Not according to your original post. Is there something else you were trying to block. The regex above should return false for digits and spaces only, true for anything else.
|
#6
|
|||
|
|||
PHP Code:
PHP Code:
|
#7
|
||||
|
||||
Quote:
The c wrapper ctype_digit() is much faster than is_numeric if your going to go that way about it. Code:
^0-9\s //Anything that does not "^" have the value of a digit "0-9" or a space "\s". ^\d\s works also and might be a bit faster PHP Code:
|
#8
|
|||
|
|||
I finally got it to work by exploding the values in the array and extracting them individually.
PHP Code:
|
#9
|
|||
|
|||
PHP Code:
|
#10
|
||||
|
||||
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|