Home > Article > Web Front-end > Debugging problems encountered with regular expressions in JavaScript_javascript tips
Regarding the problem of string testing in regular expressions, we generally have two methods: test() and exec(). I will not elaborate on the difference between these two methods here. The main thing is that test() returns Boolean value, exec() returns the matched character array, but today I encountered a problem. The program is very simple, but the problems inside make me puzzled. I couldn't find the answer when I searched for it on the Internet (personally I am not good at it).
The value of the first alert() is true as expected
But the second test value is unexpectedly null
I don’t know what the reason is for this problem because I haven’t seen the source code of the function. If anyone can point it out, I’d be grateful! !