Regex to match username using negative look aheads? -


i want use regex such i'm given list of matches username there not "." present in name

account name: sasha.grey //bad match

account name: liz.hurley //bad match

account name: sharonstone //match

tried out regex:

account name:\s+(.*?(?!.))

i have tried match on regexbudy , result doesn't work in both cases.

i think vks answer correct.

another way (avoiding lookaheads @ all) match . , \n (and whatever character should not in account name

account name:\s+([^.\n]+)$ 

edit: $ mark end of line (oder end of file - depends on flavor). might want use \n instead.

maybe want know expression doing:

\s+(.*?(?!.)) 

is not working because match

  • \s+ whitespace (one or more occurences)
  • .*? character (one or many, less possible)
  • (?!.) not any character \n

    if wanted ignore literal ., have escape (so it's (?!\.) or (?![.]) - then, still not work since description is: lookahead non literal dot. this, match '' .*? in every of examples


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -