正则表达式中\A,\z和^的区别
1个回答
展开全部
^从行开始处匹配,$从行结束处开始匹配。
\A从字符串开始处匹配,\Z从字符串结束处匹配。
例如:
("this is\nthe time",/^the/)
=>this is\n<<the>> time
("this is\nthe time",/is$/)
=>this <<is>>\nthe time
("this is\nthe time",/\Athis/)
=><<this>> is\nthe time
("this is\nthe time",/\Athe/)
=>no match
("this is\nthe time",/time\Z/)
=>this is\nthe <<time>>
("this is\nthe time",/time\z/)
=>this is\nthe <<time>>
("this is\nthe time",/is\Z/)
=>no match
("this is\nthe time",/is\z/)
=>no match
\A从字符串开始处匹配,\Z从字符串结束处匹配。
例如:
("this is\nthe time",/^the/)
=>this is\n<<the>> time
("this is\nthe time",/is$/)
=>this <<is>>\nthe time
("this is\nthe time",/\Athis/)
=><<this>> is\nthe time
("this is\nthe time",/\Athe/)
=>no match
("this is\nthe time",/time\Z/)
=>this is\nthe <<time>>
("this is\nthe time",/time\z/)
=>this is\nthe <<time>>
("this is\nthe time",/is\Z/)
=>no match
("this is\nthe time",/is\z/)
=>no match
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询