接受空格和减号的正则表达式? [英] regular expression to accept space and minus sign ?
本文介绍了接受空格和减号的正则表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个允许使用
的正则表达式
以下格式:
-1.00
1.00
-1.00(负号与数字之间不能有空格)
我写了一个正则表达式为*(-?)\ s?\ $?([0-9 \.] *)
但它不适合-1.00(带空格),谁能帮助我?
Hi i want a regular expression which will allow
following formats :
- 1.00
1.00
-1.00(no space between minus and digits)
i wrote a reg ex as *(-?)\s?\$?([0-9\.]*)
but its not working for - 1.00(with space ) can anyone help me ?
推荐答案
?([0-9 \.] *)
但不适用于-1.00(带空格),谁能帮我?
?([0-9\.]*)
but its not working for - 1.00(with space ) can anyone help me ?
您可以尝试从此链接中找到完全匹配的内容
http://regexlib.com/ [
You can try to find your exact match from this link
http://regexlib.com/[^]
满足您要求的正则表达式如下:
^(\-* \ s * [0-9] + \.[0-9] +)
Regular Expression for your Requirement follows:
^(\-*\s*[0-9]+\.[0-9]+)
这篇关于接受空格和减号的正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文