Skip to content

Commit 8a8df06

Browse files
committed
simplify the LINE_PATTERN regex
as for the start and end anchors (`^` & `$`), they're unnecessary since we apply this regex to separate lines, not whole text
1 parent 34afe66 commit 8a8df06

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/tools/jsondocck/src/main.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ use directive::{Directive, DirectiveKind};
1616
static LINE_PATTERN: LazyLock<Regex> = LazyLock::new(|| {
1717
RegexBuilder::new(
1818
r"
19-
^\s*
20-
//@\s+
21-
(?P<negated>!?)
22-
(?P<directive>[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)
23-
(?P<args>.*)$
24-
",
19+
# Any number of whitespaces.
20+
\s*
21+
# The directive prefix (`//@`) and 1 or more whitespaces after.
22+
//@\s+
23+
# The directive itself (1 or more word or `-` characters).
24+
(?P<directive>[\w-]+)
25+
# The optional remainder (1 non-word character and 0 or more of any characters after).
26+
(?P<args>\W.*)?
27+
",
2528
)
2629
.ignore_whitespace(true)
2730
.build()

0 commit comments

Comments
 (0)