Day 353 – still stuck with RegEx
I am just simply not getting through with jQuery Regex
I would like to test syntax 9.3x1.3
where the nums can be any amount like 12.5x11.3
is also accepted, the important part is that it must be one or two num dot num x one or two num dot num
I online tested the /[0-9].[0-9][x] [0-9].[0-9]
version online but doesnt seems to be working in RL. RegEx seems to be an out-of-world thing to me…
2
Answers
I hope this works for you
d
is a convenience syntax for[0-9]
/^d{1,2}.dxd{1,2}.d$/
This should match the syntax described: one or two num dot num x one or two num dot num
Edit: added test
Your regex was in the right direction, it only missed the valid length of each section.
[0-9]
means one digit is allowed. Need to use{min, max}
to set valid length.It should be like this :