© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
13 replies
sashok

Regex - Match a string outside of the parentheses

How do I match any
e
e
which's not inside of the parentheses?

I have created a pattern to do it, but it doesn't seem to work properly. It should store
(
(
s and remove
)
)
s, so that an
e
e
that is outside of the parentheses is matched e.g.
()()()e
()()()e
, but
e
e
inside of the parentheses isn't e.g.
(e)
(e)
.
https://regex101.com/r/3m6ZUc/1
(?<=(?:[^()]|(?<a>\()|(?<-a>\)))+(?(a)(?!)))e
(?<=(?:[^()]|(?<a>\()|(?<-a>\)))+(?(a)(?!)))e
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Create regex that returns the match only
C#CC# / help
4y ago
❔ Match literal escape strings with a regex
C#CC# / help
3y ago