Regex: whitelist of characters + maxmim length + no dot at the end -
i not know why i'm struggling simple regex, :)
i need regex match string:
with allowed characters[a-za-z0-9_.-] that contains 1 48 characters that can have dots, not @ end of string tried bunch of regexes, there's slips through matching. ended with
^([a-za-z0-9_.-]{1,48})([^.])$ for reason, test$ illustration accepted valid. test$$ isn't.
can help me on right track here?
you can utilize negative lookbehind if supported regex engine:
^[a-za-z0-9_.-]{1,48}(?<!\.)$ demo
if regex engine doesn't back upwards negative lookbehinds, supports negative lookaheads, next work you:
^(?!.*\.$)[a-za-z0-9_.-]{1,48}$ demo
regex dot
No comments:
Post a Comment