Home > Mobile >  Pattern for a specific ending of letters (words)
Pattern for a specific ending of letters (words)

Time:12-10

Is it possible to do the following: Only letters and numbers passed in the input, and also, at the end of the line, there were always letters/words: xls, xslx, json, xml.

Currently using this pattern:

Validators.pattern(/^[a-zA-Z0-9] $/)

CodePudding user response:

With a non-capturing group to match any mentioned words at the end.

^[a-zA-Z0-9] (?:xls|xlsx|json|xml)$

Demo @ Regex101

  • Related