Quantcast
Channel: CodeProject Latest postings for Regular Expressions
Viewing all articles
Browse latest Browse all 224

Matching exact string with a vertical bar and square brackets

$
0
0
I want to match exact strings with a vertical bar and square brackets, but I want to match the shortest possible.
Meaning, I want to match the string
[aaa|bbb]
not anything in this
[aaa] | [bbb]
or this
[aaa] | [aaa|bbb] (in this example, I only want [aaa|bbb], and want the the first [aaa] be ignored (not matched)
so I can't use the regex:
\[.*?\|(.*?)]
It can have non-alphabetical chars, like this [aaa|(ccc)bbb], or be in different languages.
What can I do?

Viewing all articles
Browse latest Browse all 224

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>