You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lookahead and lookbehind asserts allow you to specify that text ahead or behind the current parsing position matches a particular pattern, without that match being captured, or the characters being consumed.
158
+
[Lookahead](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion) and [lookbehind](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion) asserts allow you to specify that text ahead or behind the current parsing position matches a particular pattern, without that match being captured, or the characters being consumed.
159
159
160
160
There are four types of assertions:
161
161
162
-
-`(?=...)`: A positive lookahead assertion specifies a pattern than the following characters must match.
163
-
-`(?!...)`: A negative lookahead assertion specifies a pattern than the following characters must not match.
164
-
-`(?<=...)`: A positive lookbehind assertion specifies a pattern than the preceding characters must match.
165
-
-`(?<!...)`: A negative lookbehind assertion specifies a pattern than the preceding characters must not match.
162
+
-`(?=...)`: A positive lookahead assertion specifies a pattern that the following characters must match.
163
+
-`(?!...)`: A negative lookahead assertion specifies a pattern that the following characters must not match.
164
+
-`(?<=...)`: A positive lookbehind assertion specifies a pattern that the preceding characters must match.
165
+
-`(?<!...)`: A negative lookbehind assertion specifies a pattern that the preceding characters must not match.
166
166
167
-
Lookahead and lookbehind assertions do not match intuitively.
167
+
Be careful when using lookahead and lookbehind assertions with `URLPattern`, as there is some behavior you may find unintuitive.
168
168
For example, you would expect the following lookahead assertion to match a `pathname` of `/ab`, but this is not what happens.
When a pattern is parsed it is automatically normalized to a canonical form.
409
-
For example, Unicode characters are percentencoded in the pathname property, punycode encoding is used in the hostname, default port numbers are elided, paths like `/foo/./bar/` are collapsed to just`/foo/bar`, etc.
409
+
For example, Unicode characters are [percent-encoded](/en-US/docs/Glossary/Percent-encoding) in the pathname property, punycode encoding is used in the hostname, default port numbers are elided, paths like `/foo/./bar/` are collapsed to `/foo/bar`, etc.
410
410
In addition, there are some pattern representations that parse to the same underlying meaning, like `foo` and `{foo}`.
411
411
Such cases are normalized to the simplest form.
412
-
In this case `{foo}`gets changed to `foo`.
412
+
In this case `{foo}`is normalized to `foo`, for example.
413
413
414
414
## Inheritance from a base URL
415
415
@@ -632,9 +632,9 @@ try {
632
632
633
633
The following example shows how input values that match pattern groups can later be accessed from the {{domxref("URLPattern/exec","exec()")}} result object.
634
634
635
-
The `input` property is the string that is matched by the pattern: in this case`cdn.example.com`.
635
+
The `input` property is the string that is matched by the pattern: in this case it's `cdn.example.com`.
636
636
The `groups` property contains captured groups, indexed by number for unnamed groups, and name for named groups.
637
-
In this case there is just one unnamed group for the wildcard property, with the value `cdn`.
637
+
In this case, there is only one unnamed group for the wildcard property, with the value `cdn`.
0 commit comments