Get numbers from string with regex

前端 未结 5 1999
Happy的楠姐
Happy的楠姐 2020-12-07 00:27

I am trying to write a regex to get the numbers from strings like these ones:

javascript:ShowPage(\'6009\',null,null,null,null,null,null,null)
javascript:Bloc         


        
5条回答
  •  青春惊慌失措
    2020-12-07 01:05

    Assuming:

    • you want to capture the digits
    • there's only one set of digits per line

    Try this:

    /(\d+)/
    

    then $1 (Perl) or $matches[1] (PHP) or whatever your poison of choice is, should contain the digits.

提交回复
热议问题