我从这个链接中了解到,这两个区限匹配有些相似:
我也看过同一个链接末尾提供的
\G
和 ^
。我也看过同一个链接末尾提供的
\G
示例。 Enter your regex: dog
Enter input string to search: dog dog
I found the text "dog" starting at index 0 and ending at index 3.
I found the text "dog" starting at index 4 and ending at index 7.
Enter your regex: \Gdog
Enter input string to search: dog dog
I found the text "dog" starting at index 0 and ending at index 3.
与没有边界匹配器相比,这非常清晰明了,但是对于以下情况:
Enter your regex: \Gdog
Enter input string to search: dog dog
I found the text "dog" starting at index 0 and ending at index 3.
vs
Enter your regex: ^dog
Enter input string to search: dog dog
I found the text "dog" starting at index 0 and ending at index 3.
这两者之间有什么微妙的区别?