Get the first integers in a string with JavaScript

前端 未结 5 1692
谎友^
谎友^ 2020-12-02 10:23

I have a string in a loop and for every loop, it is filled with texts the looks like this:

\"123 hello everybody 4\"
\"4567 stuff is fun 67\"
\"12368 more st         


        
5条回答
  •  忘掉有多难
    2020-12-02 11:07

    If you want an int, just parseInt(myString, 10). (The 10 signifies base 10; otherwise, JavaScript may try to use a different base such as 8 or 16.)

提交回复
热议问题