Regular Expressions .NET

Posted by Fosa on Stack Overflow See other posts from Stack Overflow or by Fosa
Published on 2013-11-03T21:40:42Z Indexed on 2013/11/03 21:54 UTC
Read the original article Hit count: 199

Filed under:
|
|
|

I need a regular expression for some arguments that must match on a string.

here it is...

  1. The string exists out of minimum 8 en maximum 20 characters.

  2. These characters of this string may be characters of the alfabet or special chars --With other words..all charachters except from the whitespaces

  3. In the complete string there must be atleast 1 number.

  4. The string cannot start with a number or an underscore

  5. The last 2 characters of the string must be identical, But it doenst matter if those last --identical characters are capital or non-capital (case insensitive)

Must match all :

+234567899
a_1de*Gg
xy1Me*__
!41deF_hij2lMnopq3ss
C234567890123$^67800
*5555555
sDF564zer""
!!!!!!!!!4!!!!!!!!!!
abcdefghijklmnopq9ss

May not match :

Cannot be less then 8 or more then 20 chars:

a_1+Eff
B41def_hIJ2lmnopq3stt

Cannot contain a whitespace:

A_4 e*gg
b41def_Hij2l nopq3ss

Cannot start with a number or an underscore: __1+Eff 841DEf_hij2lmnopq3stt

cannot end on 2 diffrent characters:

a_1+eFg
b41DEf_hij2lmnopq3st

Cannot be without a number in the string:

abCDefghijklmnopqrss
abcdef+++dF
!!!!!!!!!!!!!!!!!!!!
------------------------------------------------------

This is what I have so far...But I'm really breaking my head on this... If you Don't know the answer completely it's not a problem... I just want to get in the right direction

([^0-9_])(?=.*\d)(\S{8,20})(?i:[\S])\1

© Stack Overflow or respective owner

Related posts about .NET

Related posts about regex