When should I use \A in a regex?

前端 未结 4 791
暗喜
暗喜 2021-02-19 05:32

End of line anchor $ match even there is extra trailing \\n in matched string, so we use \\Z instead of $

For example

4条回答
  •  清酒与你
    2021-02-19 05:39

    Most often it's used when also enabling multi-line matches. Since \A only matches at the beginning of the ENTIRE text, as opposed to just a line beginning, in regexes that can match across lines the functionality of ^ and \A are different.

提交回复
热议问题