我只想接受一定百分比的符号(选择)作为数字的直观变量,就像投入的百分比一样。 E.G, 1000%或100%,或2000年可能,或显示投入为1000或2000年。
我们能否在定期表达的帮助下这样做? 或者可能还有其他一些验证。
请帮助
我只想接受一定百分比的符号(选择)作为数字的直观变量,就像投入的百分比一样。 E.G, 1000%或100%,或2000年可能,或显示投入为1000或2000年。
我们能否在定期表达的帮助下这样做? 或者可能还有其他一些验证。
请帮助
following
^[+-]?d+(.d+)?%?$
应同男性工作者合作
^[0-9]+%?$
假设至少需要一名数字,只允许肯定数字(或<代码>0)。
如果你也想允许诽谤(你本可以提到这个问题的话),那么尝试
^[0-9]+(?:.[0-9]+)?%?$
这使得任何积极的分类或分类(但并非如<条码>.1代码>或<条码>。 当然,接触性标志没有得到支持。
Absolutely. It sounds like you want to sanitize here as well, so "[0-9]{1,}%" or "[0-9]*.?[0-9]{1,}%" to ensure you match fractional percentages.
通常,我可能已经说过,但太少了(fun.org)。 EDIT
rel=“nofollow”>http://www.ual-expressions.info/vis.html
You could do it with a something besides a regex but that would just be a loop that asserts that each character of input is a decimal digit, period, or percent sign, and that they are in the appropriate order.
Hope this helps!
根据这一评论:
it seems to work perfect with patterns like 1000%, 100 but now problems with decimal values like 101.50 or 199.50%
^[-+]?d*.?d+%?$
<>Explanion>:
"
^ # Assert position at the beginning of the string
[-+] # Match a single character present in the list “-+”
? # Between zero and one times, as many times as possible, giving back as needed (greedy)
[0-9] # Match a single character in the range between “0” and “9”
* # Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
. # Match the character “.” literally
? # Between zero and one times, as many times as possible, giving back as needed (greedy)
[0-9] # Match a single character in the range between “0” and “9”
+ # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
# Assert position at a word boundary
% # Match the character “%” literally
? # Between zero and one times, as many times as possible, giving back as needed (greedy)
$ # Assert position at the end of the string (or before the line break at the end of the string, if any)
"
As a side note : You should really have been able to account for the optional part from @ Tim s answer. Take a look at the tutorial proposed by the other answers.
You can try with the digits and % as an optional character.
^d+(.d+)?%?$
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...