Jump to content

Regular Expression


Go to solution Solved by IPCommerceFan,

Recommended Posts

Posted (edited)

Hello 
I am trying to insert a Regular Expression in a text filed that will check the value inserted by user and will validate the following:

  • Only numbers allowed
  • only 1 dot allowed
  • minimum value is 1.4

Can you please help me with the expression?

Many thanks 🙏

image.png.6021230b8eb51cdbe8b8199b74d45064.png
 

Edited by livegames.co.il
Posted (edited)
8 minutes ago, IPCommerceFan said:

Glad you figured it out!

I'm going to post this here anyway, in case someone stumbles on this thread while searching for similar:

^([1-9]\.[4-9]{1}|[2-9]{0,9}\.[0-9]{1}|[0-9]{2,9}\.[0-9]{1})$

https://regex101.com/r/iqeDII/3

Thank you, @IPCommerceFan


this is what I have done -  i thought i figure it out 😌
/^([1-9].?[4-9]|[2-9](.?[0-9])?)$/
But actually, I am struggling to do the minimum of 1.40; 
because now its accept minimum of 1.4 but reject 1.40
if you can help me, I would appreciate it.

Edited by livegames.co.il
Posted (edited)

Updated!

https://regex101.com/r/iqeDII/6

^([1-9]\.([4-9]{1}|[4-9]{1}[0-9])|[2-9]{0,9}\.[0-9]{1}|[0-9]{2,9}\.[0-9]{1,2}|[2-9]{0,9})$

My understanding was that you only wanted to use 1 decimal place (only 1 dot allowed), which is why the original pattern didn't account for 1.40.

How many decimal places should be accounted for?

Edited by IPCommerceFan
Posted

Yes, sorry for misleading you.

2 decimal max - minimum 1.40

so every decimal number above should work...with the example you sent 1.45 doesn't work i am afraid

Posted (edited)
6 minutes ago, IPCommerceFan said:

Made an edit, try this:

^(([1-9]\.([4-9]{1}|[4-9]{1}[0-9]))|[2-9]{0,9}\.[0-9]{1}|[0-9]{2,9}\.[0-9]{1,2}|[2-9]{0,9})$

 

I am sorry i am afraid its not working. 

I am checking it here 

https://regex101.com/

 

image.png.6358df92c66923f064850a827038c1d1.png

Edited by livegames.co.il
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...