-1

How can I check following string is in valid format or not? Can someone provide me regular expression to check this.

Expect format should be like :: key:valu;key2:value2;

Following are some valid and invalid strings I want to check.

k1:v1;k2:v2; => valid format
k1:v1;k2:v2 => valid format
somekey:value;k2:v2; => valid format
k1,v1;k2,v2 => invalid format
k1 v1; k2 v2; => invalid format

Thanks in advance.

1 Answers1

0

This one fulfills your specs

([a-z0-9]+):([a-z0-9]+);([a-z0-9]+):([a-z0-9]+);? 

Have a try yourself https://regex101.com/r/gxjPhY/1

mplungjan
  • 169,008
  • 28
  • 173
  • 236