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 ?
2 ответов
+ 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.
0
i think there is another for single character. use % and see what happens.