Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  1] [ 1]  / answers: 1 / hits: 34975  / 10 Years ago, thu, august 28, 2014, 12:00:00

I have a string: [2-0]>5&&[3-0]<21



I would like to pull out an array of: 2-0 and 3-0



The resulting array should look like this: [2-0, 3-0]



Does anyone know some fancy regex that will do this, or perhaps another method?


More From » jquery

 Answers
4

You could try the below code which matches the strings present inside the [] brackets,



> [2-0]>5&&[3-0]<21.match(/[^[]]+(?=])/g)
[ '2-0', '3-0' ]

[#69628] Tuesday, August 26, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
davonte

Total Points: 581
Total Questions: 101
Total Answers: 113

Location: Sudan
Member since Tue, Aug 3, 2021
3 Years ago
;