I have checked several other questions on SO like this, this, this, this, and this, but I can't seem to figure out my issue from any of these. It is quite likely that I'm missing something simple, but I don't know what.
I have a string like the following:
This is some random text{colA}that needs{COLBB} to be matched.
I need to match on the A
and the BB
but nothing else. The rules are as follows
- The prefix will only be {col (case insensitive)
- The suffix will only be }
- The characters to match will only be letters
- The match must be case insensitive
- The match will only be 1 or 2 characters
- A word break can't be assumed before or after the prefix/suffix
I managed to get this: (?i:[a-z]{1,2}(?<={col[a-z]{1,2})(?=}))
which matches {colaa}
but not {cola}
(In the case of {cola}
it returns la
when it needs to return a
). I can't figure out how to tune this to work with the two different match cases.
I'm working in .Net and would really appreciate any help I could get on this matter. I feel so close, yet so far away!