i’ve got regex which was alright, but as it camed out doesn’t work well in some situations
Keep eye on message preview cause message editor do some tricky things with ‘\’
[\[]?[\^%#\$\*@\-;].*?[\^%#\$\*@\-;][\]]
its task is to find pattern which in general looks like that
[ABA]
- A – char from set ^,%,#,$,*,@,-,;
- B – some text
- [ and ] are included in pattern
is expected to find all occurences of this pattern in test string
Black fox [#sample1#] [%sample2%] – [#sample3#] eats blocks.
but instead of expected list of matches
- ‘[#sample1#]’
- ‘[%sample2%]’
- ‘[#sample3#]’
I get this
- ‘[#sample1#]’
- ‘[%sample2%]’
- ‘- [#sample3#]’
And it seems that this problem will occur also with other chars in set ‘A’. So could somebody suggest changes to my regex to make it work as i need?
and less important thing, how to make my regex to exclude patterns which look like that
[ABC]
- A – char from set ^,%,#,$,*,@,-,;
- B – some text
- C – char from set ^,%,#,$,*,@,-,; other than A
- [ and ] are included in pattern
for example
[$sample1#] [%sample2@] [%sample3;]
thanks in advance
MTH
applied to text:
matches
[#sample1#][%sample2%][#sample3#][%sample4;]EDIT
This works for me (Output as expected, regex accepted by C# as expected):