Regular Expressions: difference between ^ and \A

后端 未结 4 1753
挽巷
挽巷 2020-12-11 07:33

Is the only difference between ^ and \\A the fact that \\A can never match after a line break? (even in multi-line mode)



        
4条回答
  •  醉梦人生
    2020-12-11 08:26

    Yes. \A will match at the very beginning of your value. ^ will match the beginning of the value, but will also match immediately after newlines in multiline mode (//m).

    The \Z is similar, but with the end of the value. However, it will also match before a newline at the end of the value. If you don't want this behaviour, use \z, which matches only at the end of the value.

    Useful reference: perlre manpage

提交回复
热议问题