Security

 View Only
  • 1.  Regular Expression on Registration Page

    Posted Oct 07, 2013 02:11 PM

    Hey,

     

    I am looking to make a regular expression that will exclude a certain string from being allowed on our registration page.

     

    The field is a simple text field.

    I am using the option IsRegexMatch.

     

    I found out that the field can accept perl regular expressions. I found this:

    \w+\b(?<!\bfox)

     Which is a negative lookbehind.

     

    I modified it to match our requirements

    \w+\b(?<!\b[fF][oO][xX])

     However it only works if the word "fox" is put in by itself.

    If you add any other word it is accepted.

     

    This will fail

    fox
    Fox
    FOX
    etc...

     This will be excepted

    Fox company
    fox company
    company fox
    company Fox
    etc...

     

    Is there an easier way to doing this?

    Or perhaps I having gone completely wrong with my regular expression.

    I had tested my regular expression here and it seemed to work okay.

     

    Thank you,

     

    Cheers



  • 2.  RE: Regular Expression on Registration Page

    Posted Oct 08, 2013 05:04 AM

    That's pretty cool - cant you just use a wild card at the end?

     

    ^\w+\b(?<!\b[fF][oO][xX])*

     

    What do you reckon? :smileywink:



  • 3.  RE: Regular Expression on Registration Page

    Posted Oct 08, 2013 08:11 AM

    I thought about that actually, well sort of.

     

    I had tried this combination

    \w+\b(?<!\b[fF][oO][xX])\w+

     The \w+ at the end is basically like a wild card as defined here.

     

    I never actually considered using just a standard '*'

    I will give it a shot and let you know the results!

     

    Thanks for the suggestion.

    ---------------------------------------------------

    I tried this

    \w+\b(?<!\b[fF][oO][xX])*

    but unfortunately it causes the field to accept everything.

     

    I also tried this

    \w+\b(?<!\b[fF][oO][xX])\w+

     but unfortunately it causes the field to fail everything.

     



  • 4.  RE: Regular Expression on Registration Page

    Posted Oct 08, 2013 08:33 AM

    Oh I actually found one that works I think

     

    ^((?![fF][oO][xX]).)*$

     Any combination it appears will be picked up

     

    Fox
    fox
    FOX
    Fox company
    company fox

     All got rejected

     

    company
    Company

     Was accepted

     

    You can extend this to into other patterns

     

    ^((?![fF][oO][xX]|[wW][oO][lL][fF]).)*$

    This would match

     

    fox or wolf

     

    The only down side that I found is that it will be rejected if the string exists inside another word

     

    So if we wanted to filter out 'over' and you typed 'overly' the string will get rejected.

     

    For what we need it for though it should work.

     

    credit where credit is due

     

    Thanks guys!

     

    Cheers