Unable to get regex working -


i have third party application lets me enter regular expression validate user input in text box. need user input data in format c:64gb, f:128gb h:32gb. regex wrote:

\b[a-z]{1}[:]?\d*(gb|gb)\b 

this regex works fine validates first block. if write c:64gb f:128, marks input valid. not check f:128 makes input invalid. should c:64gb f:128gb.

when change regex ^\b[a-z]{1}[:]?\d*(gb|gb)\b$, allows me enter c:64gb.

what doing wrong here?

you can use regex:

^(\w*[a-za-z]:?\d+(?:gb|gb)\w*)+$ 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -