Regular expression

Hello,

I have a user entire field that takes in a version number example 0.8.7 or 00.23.25.

  1. how do i write this in regular expression.
  2. how do i make sure the format is respected when the user enters the version number

I have the following but I have a feeling im not doing this right:

<input type="text" name="txt_newVersion" placeholder="Enter new project version" id="txt_newVersion" pattern="/[0-9][0-9]+\.[0-9][0-9]+\.[0-9][0-9]/mg;"><br>

Any help you can provide would be greatly appreciated.
thanks

0.8.7 fails according to your existing regular expression. Iā€™d just use \d+ to say one or more numbers in a row, instead of [0-9][0-9]+

You can test things out at https://regex101.com/

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.