javascript - optimization of a regular expression
伊谢尔伦
伊谢尔伦 2017-05-19 10:09:54
0
4
572

Matches the integer of 1024-65535, that is, 65535 >= x >= 1024. Use regular rules to write it. Mine is
/^(102[4-9]|10[3-9]d {1}|1[1-9]d{2}|[2-9]d{3}|[1-5]d{4}|6[0-4]d{3}|65[0- 4]d{2}|655[0-2]d{1}|6553[0-5])$/
Is there a more concise and optimized way of writing

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(4)
小葫芦

What's going on? I feel like it's easier to convert this thing into a number and then convert it into a string... I don't know your specific situation

某草草

First subtract 1024 from the number you got and then do the matching. It will be a little simpler d{1,4}|[1-5]d{4}|6[1-3]d{3}|64[1-4]d{2}|6450d|6451[01]
Standing for the answers from all the heroes

我想大声告诉你

/^(6[0-4]d{3}|65[0-4]d{2}|655[0-2]d|6553[0-5]d|[1-5]d{4}|[2-9]d{3}|1d[3-9]d|102[4-9])$/

滿天的星座

Why not just compare the sizes directly. . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template