字符串末尾的正则表达式为数字? [英] Regex for number at the end of string?
本文介绍了字符串末尾的正则表达式为数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想确定字符串是否以数字结尾(带/不带小数).如果结束,我要提取它.
I want to find out if a string ends with number (with/without decimal). If it ends, I want to extracts it.
"Test1" => 1
"Test" => NOT FOUND
"Test123" => 123
"Test1.1" => 1.1
我错过了一些细节.
1.在数字之前,字符串还可以包含特殊字符
2.它是单行,而不是多行.
I have missed a few details.
1. Prior to number, string can contain special characters also
2. It is single line, not multiline.
推荐答案
尝试一下此模式,
\d+(\.\d+)?$
这篇关于字符串末尾的正则表达式为数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文