Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Regex:
- (?x)\[ # First '['
- (?:
- [^\[\]]+ # Match everything that's not "[]"
- |
- (?<open> \[ ) # Match '[', and capture into 'open'
- |
- (?<-open> \] ) # Match ']', and delete the 'open' capture
- )+
- (?(open)(?!)) # Fails if 'open' stack isn't empty!
- \] # Last opening ']'
- Tested with:
- possible-text [posibility-1/posibility-2] possible-text [[un/]certain/[un/]sure] some-text [I am/I'm] [[un/]certain/[/un]sure]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement