The understanding of asterisks in JavaScript regularization?

var str  = "12 fff 56 ffg2334";
console.log(str.match(/\d*/g))
*0

clipboard.png


Zero-Length Regex Matches
https://www.regular-expressio.
for example, if you use \ b to match abcd , you can find that the head and tail are matched


. I am also curious about the problem that numbers can be matched without asterisks, and it is strange to have asterisks. Just found the information, you can take a look at


personal guess: in
C language, there is a hidden\ 0 at the end of the string. I don't know if there is this guy at the end of the string in js (js is not familiar with). The
match function has to run the whole string. It's gone at the end. * represents 0 to more,\ 0 is 0 digits. So I returned "
" to you. I thought you wanted to get 1256 2334 * instead of +


.

if you can understand that \ d {0} is treated as a null character, that's fine. Empty characters are actually positions, similar to ^ and $, see the following code

"1x".match(/\d{0}/g)
// => ["", "", ""] 

Welcome to https://pan.baidu.com/s/1qYeC0ri

Menu