REGEX - Allow Numbers and . - /

前端 未结 5 780
予麋鹿
予麋鹿 2021-01-13 19:10

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

It should allow something like that:

011.235673.98923/0001-12

相关标签:
5条回答
  • 2021-01-13 19:28

    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.

    0 讨论(0)
  • 2021-01-13 19:34

    How about something like

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

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

    0 讨论(0)
  • 2021-01-13 19:37
    ^[\d./-]*$
    

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

    0 讨论(0)
  • 2021-01-13 19:38

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

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

    edit: Forgot to add the / sry

    0 讨论(0)
  • 2021-01-13 19:48

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

    0 讨论(0)
提交回复
热议问题