diff --git a/README.md b/README.md
index 3f6eb5c..d7c5f32 100644
--- a/README.md
+++ b/README.md
@@ -212,8 +212,8 @@ Using a high limit has a small impact on performance. Generally, this is only a
Advanced pattern options that override standard error checking and flags when enabled.
- `allowOrphanBackrefs`: Useful with TextMate grammars that merge backreferences across patterns.
-- `allowUnhandledGAnchors`: Applies flag `y` for unsupported uses of `\G`, rather than erroring.
- - Oniguruma-To-ES uses a variety of strategies to accurately emulate many common uses of `\G`. When using this option, if a `\G` is found that doesn't have a known emulation strategy, the `\G` is simply removed and JavaScript's `y` (`sticky`) flag is added. This might lead to some false positives and negatives, but is useful for non-critical matching (like syntax highlighting) when having some mismatches is better than not working.
+- `allowUnhandledGAnchors`: Removes unsupported uses of `\G`, rather than erroring.
+ - Oniguruma-To-ES uses a variety of strategies to accurately emulate many common uses of `\G`. When using this option, if a `\G` is found that doesn't have a known emulation strategy, the `\G` is simply removed. This might lead to some false positive matches, but is useful for non-critical matching (like syntax highlighting) when having some mismatches is better than not working.
- `asciiWordBoundaries`: Use ASCII-based `\b` and `\B`, which increases search performance of generated regexes.
- `captureGroup`: Oniguruma option `ONIG_OPTION_CAPTURE_GROUP`. Unnamed captures and numbered calls allowed when using named capture.
diff --git a/demo/index.html b/demo/index.html
index 48f19e2..6db978f 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -120,7 +120,7 @@
Try it
diff --git a/spec/match-search-start.spec.js b/spec/match-search-start.spec.js
index a11a646..bbc99b0 100644
--- a/spec/match-search-start.spec.js
+++ b/spec/match-search-start.spec.js
@@ -135,7 +135,7 @@ describe('Assertion: Search start', () => {
];
patterns.forEach(pattern => {
expect(() => toDetails(pattern)).toThrow();
- expect(toRegExp(pattern, {rules: {allowUnhandledGAnchors: true}}).sticky).toBe(true);
+ expect(() => toDetails(pattern, {rules: {allowUnhandledGAnchors: true}})).not.toThrow();
});
});
});
diff --git a/src/options.js b/src/options.js
index 429d739..b866de0 100644
--- a/src/options.js
+++ b/src/options.js
@@ -55,7 +55,7 @@ function getOptions(options) {
rules: {
// Useful with TextMate grammars that merge backreferences across patterns.
allowOrphanBackrefs: false,
- // Applies flag `y` for unsupported uses of `\G`, rather than erroring.
+ // Removes unsupported uses of `\G`, rather than erroring.
allowUnhandledGAnchors: false,
// Use ASCII-based `\b` and `\B`, which increases search performance of generated regexes.
asciiWordBoundaries: false,
diff --git a/src/transform.js b/src/transform.js
index e248520..31ee3a0 100644
--- a/src/transform.js
+++ b/src/transform.js
@@ -140,10 +140,11 @@ const FirstPassVisitor = {
// string-terminating line feed
replaceWith(parseFragment(r`(?<=\A|\n(?!\z))`));
} else if (kind === AstAssertionKinds.search_start) {
- if (!supportedGNodes.has(node) && !allowUnhandledGAnchors) {
+ if (supportedGNodes.has(node)) {
+ ast.flags.sticky = true;
+ } else if (!allowUnhandledGAnchors) {
throw new Error(r`Uses "\G" in a way that's unsupported`);
}
- ast.flags.sticky = true;
remove();
} else if (kind === AstAssertionKinds.string_end_newline) {
replaceWith(parseFragment(r`(?=\n?\z)`));