RegExp that match everything except letters
javascript, regex
Solution
What do I have to do yet to match everything except letters at any position of my input String?
You need to use regular expression flags to achieve this
try this
'1qwe2qwe'.match(new RegExp(/[^a-zA-Z]+/g))
it should return `["1", "2"]`
the `g` flag at end of the regexp tells regexp engine to keep traversing the string after it has found one match. Without `g` flag it just abandons traversal upon finding first match. You can find the reference here
Problem
I'm trying to write RegExp that match everyting except letters. So far, I've wrote something like this: ``` /[^a-zA-Z]+/ ``` However, during tests, I've found that it works nicely when I write for example: 'qwe' or 'qqqqqweqwe123123' or something similar, BUT when I start String from number for example: '1qweqwe', it doesn't match. What do I have to do yet to match everything except letters at any position of my input String? Thanks in advance. Edit: Correct RegExp I found is: ``` /^[^a-zA-Z]*$/ ```