java - In regex difference betewen \\G and ^ -
i see link these 2 boundary matches quite similar: \g , ^.
i have seen example of \g have shown @ end of same link.
enter regex: dog enter input string search: dog dog found text "dog" starting @ index 0 , ending @ index 3. found text "dog" starting @ index 4 , ending @ index 7. enter regex: \gdog enter input string search: dog dog found text "dog" starting @ index 0 , ending @ index 3. it's clear compared no boundary matchers, about:
enter regex: \gdog enter input string search: dog dog found text "dog" starting @ index 0 , ending @ index 3. vs
enter regex: ^dog enter input string search: dog dog found text "dog" starting @ index 0 , ending @ index 3. what subtle difference between 2?
this explains \g
https://forums.oracle.com/thread/1255361
\g start searches start of string , keep searching after first match ended.
^ give 1 result search ends if match found @ beginning of search
Comments
Post a Comment