How to extract numbers from string using regular expression
Mar 19, 2018 pm 04:25 PMThis time I will bring you regular expressionsHow to extract numbers from strings, regular expressions for extracting numbers from stringsNotes What are they? Here are actual cases. Let’s take a look.
1 var str = '确定人民币¥115.625';2 var pat = /[\d]+[.][\d]+/;3 document.write(str.match(pat));//115.62511
Solve the problem that parseFloat cannot extract the first character in string is a non-digit.
Similarly, parseInt can be used /[\d]+/
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website Other related articles!
Recommended reading:
Request cross-domain solution CORS
What are the rules for converting JS type values to Boolean types
The above is the detailed content of How to extract numbers from string using regular expression. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of the method of converting int type to string in PHP

How to determine whether a Golang string ends with a specified character

How to repeat a string in python_python repeating string tutorial

How to check if a string starts with a specific character in Golang?

How to solve the problem of Chinese garbled characters when converting hexadecimal to string in PHP

PHP String Matching Tips: Avoid Ambiguous Included Expressions

PHP string manipulation: a practical way to effectively remove spaces

PHP techniques for deleting the last two characters of a string
