regexqregexp

Match float numbers separated by semicolon


I use a regexp validator and I want to restrict the use of anything but the pattern:

5414.1;123;412.1;41241;...

I tried to use [0-9;\.]* but I can't make it match only patterns which contain one(1) point after the text and before ;.

I tested using http://regexpal.com/.


Solution

  • That is not perfect, too, but is already in the near... for example it allowed -01.5.

    ((-|)[0-9]+(\.[0-9]*[1-9]|)\;)*(-|)[0-9]+(\.[0-9]*[1-9]|)
    

    Instead an (x|) -like expression you can also use x?. (Thanks @OGHaza)