Reputation: 1597
I have expressions with this form...
@@name<·parameters·>
...and I want a regular expression that matches the groups name
and parameters
. As I have a closed (and small) group of values for name
I preffer to use a for loop to try with all the few values, but parameters
can be anything... anything except <·
and ·>
, wich are the sequences for opening and closing sets of parameters.
I found this question and I tried this...
@@(name)<·((?!(<·|·>).*))·>
...but I can't get it working. I think that the reason is that there the excluded expression is known in position and in number of repetitions (1) but in my case I want to exclude every occurrence of any of this two sequences in a string of unknown length.
Do you know how to do it? Thank you.
Upvotes: 2
Views: 858
Reputation: 1862
You can also use the following regex:
@@([^<]*)<\·([^\·]+)\·>
Upvotes: 0
Reputation: 174776
You regex must be,
@@(name)<·((?:(?!<·|·>).)*)·>
Negative lookahead method. Just understand this part (?!<·|·>).
only which matches any character(dot) but not of <·
or ·>
, (?:(?!<·|·>).)*
zero (star) or more times.
or
Non-greedy method.
@@(name)<·(.*?)·>
Upvotes: 2