0

Regexp with arrays and elements (Js)

Language is JS Suppose we have an array full of positive and negative integers in a string with other letters (e.g. 1a or -2d), the question is how can you call all the strings that starts or contain positive integers using regexs? I'm new to regexs and from what I've learned I tried to use /^[0-9]/.tes...... , but It didn't work, so, any other solutions that you think might work ?

23rd Apr 2018, 2:12 AM
BRKOTTA
BRKOTTA - avatar
2 Respostas
+ 2
You will want to capture digits with or without the minus sign. For example: (-?/d+) This will match the minus 0 or 1 times, and any digit (equivalent to your [0-9]) 1 or more times.
23rd Apr 2018, 4:22 AM
ServantCoder
ServantCoder - avatar
0
i think there is another for single character. use % and see what happens.
23rd Apr 2018, 2:43 AM
Akib
Akib - avatar