The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Regular Expression Help
I have spammers signing up to my forum and entering the word "Viagra" in one of my custom fields. You can now use pattern matching in custom fields and I need help in creating a regular expression to check the field. I would like the regex to fail if the custom field contains the work Viagra. Hop someone can help.
|
#2
|
||||
|
||||
You could do something like this.
PHP Code:
|
#3
|
|||
|
|||
I was hoping of something more along the line of
^[0-9]{7,8}$ Here is the blurb for VB's help ... Regular Expression (Select, Input, Radio, Textarea only) You may require this field's contents to match a PCRE-type regular expression. For example, you could have a field that is for the user's ICQ number. Since ICQ numbers consist of only numerals, you could write a regular expression to check for non-numerals. Example: (Do not start or end the expression with an escape character) ^[0-9]{7,8}$ If you want to allow an empty response to be given, you need to account for it within the regex: ^[0-9]{7,8}$|^$ |
#4
|
||||
|
||||
If you only want to block the word 'viagra' you could try this...
This will allow anything other than the word viagra, also allows a blank field Code:
^viagra$|^$ Code:
^.*viagra.*$|^$ |
#5
|
|||
|
|||
I tried both regexs and they did not work.
|
#6
|
||||
|
||||
Oops, you're right. The regex I gave you would require you to enter 'viagra' or a blank string. I tested this a bit, and it looks like it works, although it looks so ugly that there must be a better way to do it. I need to brush up on my regexes. Note that this matches any string that contains the string 'viagra'
^[^v]*[^i]*[^a]*[^g]*[^r]*[^a]*$|^$ |
#7
|
|||
|
|||
Thanks, ill give it a shot.
|
#8
|
||||
|
||||
Let me know if it works for you.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|