Regular Expression match lines starting with a certain character OR whitespace and then that character

后端 未结 3 1897
栀梦
栀梦 2021-02-02 10:03

I am trying to write a regular expression that matches lines beginning with a hyphen (-) OR that begins with spaces or tabs and then has a hyphen. So it should match the followi

3条回答
  •  野性不改
    2021-02-02 10:13

    You can try

    ^\s*-
    
    • ^: start of string
    • \s*: zero or more whitespace characters
    • -: a literal - (you don't need to escape this outside a character class)

提交回复
热议问题