开发者

REGEX - Allow Numbers and . - /

I need a regular expression to allow just numeric and (.-/)

It should allow something like that:

011.235673.开发者_如何学JAVA98923/0001-12


The pattern you're looking for, that matches only those strings with numbers, ., -, and /:

^[0-9\.\-\/]+$

If you have a specific language you're looking to implement this I may be able to help you.


You're looking for ^[\d./-]+$


to be sure it's in right order and require every part

^(\d+)(\.(\d+))*(\/(\d+))*-(\d+)$

edit: Forgot to add the / sry


^[\d./-]*$

does this. What regex flavor are you using? Perhaps it needs to be adjusted for it.


How about something like

(\d|\.|\-|\/)*

Does it matter how many - and . and / you get? Does the order matter?


You can use this item

[^1-9]

To view its performance, refer to the following link regex101


This should do the work

^[\d\.\-\/]+$

If your sequence to be matched isn't at the start of the string, you can skip the ^. Similarly, $ is required to match sequence at the end of string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜