In a regular expression, match one thing or another, or both

前端 未结 5 1404
悲哀的现实
悲哀的现实 2020-11-28 14:35

In a regular expression, I need to know how to match one thing or another, or both (in order). But at least one of the things needs to be there.

For example, the fol

5条回答
  •  野性不改
    2020-11-28 14:43

    Yes, you can match all of these with such an expression:

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

    Note, it also doesn't match the empty string (your last condition).

提交回复
热议问题