When should I use \A in a regex?

前端 未结 4 740
北荒
北荒 2021-02-19 05:10

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:57

    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.

提交回复
热议问题