Skip to content

Exclude a Pattern in regex When Matching Another Pattern #1249

Answered by BurntSushi
Sophanatprime asked this question in Q&A
Discussion options

You must be logged in to vote

What you're looking for is a way to represent the "complement" of a regex. While that operation (along with intersection) is closed under regular languages, and this crate only supports patterns expressing a regular language, this crate does not support either (complement or intersection). You'll need to write out the complement yourself (which is often tricky and very large) or match a second regex (which isn't always possible depending on what you're doing, but usually is).

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Sophanatprime
Comment options

Answer selected by Sophanatprime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants