Regex with all optional parts but at least one required

前端 未结 4 583
我寻月下人不归
我寻月下人不归 2020-12-22 02:03

I need to write a regex that matches strings like \"abc\", \"ab\", \"ac\", \"bc\", \"a\", \"b\", \"c\". Order is important and it shouldn\'t match multiple appearances of th

4条回答
  •  天涯浪人
    2020-12-22 02:09

    ^(?=.)a?b?c?$
    

    This will check if there is at least one character with lookahead and will match your regex.

提交回复
热议问题