What do `?i` and `?-i` in regex mean?

后端 未结 3 801
误落风尘
误落风尘 2020-11-30 01:30

Could someone explain what (?i) and (?-i) wrapping a word in regex mean?

(?i)test(?-i)

I tested and it matches

3条回答
  •  执念已碎
    2020-11-30 02:13

    (?i) turns on case-insensitive mode, (?-i) turns it off.

    For example, if you tried (?i)te(?-i)st, it would match test, TEst, tEst, but not teST.

提交回复
热议问题