Regex to define right text patterns with every part, that could be unnecessary -


i need validate strings regex. string have following form:

0m 1d 2h 3m

every part of string unnecessary, letters should written in alphabetical order provided here: m, d, h, m.

so regex should implement match these patterns here :

1m 2d 3h 4m

5m 6d

7d 8h

9h 10m

11m

12d

13h

14m

also, should mention there digits 0-100 in required string patterns

if can have middle terms skipped in pattern eg. 1m 3h or 1m 4m can use it:

"^((100|[0-9]{1,2})m\s*)?((100|[0-9]{1,2})d\s*)?((100|[0-9]{1,2})h\s*)?((100|[0-9]{1,2})m\s*)?$" 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -