How to match “anything up until this sequence of characters” in a regular expression?

后端 未结 12 2318
旧时难觅i
旧时难觅i 2020-11-22 11:51

Take this regular expression: /^[^abc]/. This will match any single character at the beginning of a string, except a, b, or c.

If you add a *

12条回答
  •  深忆病人
    2020-11-22 12:31

    .*(\s)*?(?=abc)
    

    For those who want to include line breaks too.

    It will match anything and everything(including line breaks(no matter how many or even if no line break) ) until abc is found.

提交回复
热议问题