Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted April 19, 20222 yr 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 🙏 Edited April 19, 20222 yr by livegames.co.il
April 19, 20222 yr 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
April 19, 20222 yr Author 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 April 19, 20222 yr by livegames.co.il
April 19, 20222 yr 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 April 19, 20222 yr by IPCommerceFan
April 19, 20222 yr Author 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
April 19, 20222 yr 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})$
April 19, 20222 yr Author 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/ Edited April 19, 20222 yr by livegames.co.il
April 19, 20222 yr Solution Ah yes, try this: ^(([1-9]\.([4-9]{1}|[4-9]{1}[0-9]))|[2-9]{0,9}\.[0-9]{1,2}|[0-9]{2,9}\.[0-9]{1,2}|[2-9]{0,9})$
April 19, 20222 yr Author Its works perfect!! @IPCommerceFan Thanks a lot for your time and effort! It is Well appreciated.