Regex - Match a Pattern Before a Character
c#, regex
Solution
You need a positive lookahead assertion:
([A-Z]{1,3})(?==)
Problem
I'm currently building a toy assembler in c# (going through The Elements Of Computing Systems book). I need to match a very simple pattern, I thought this would be a good time to learn some regex but I'm struggling! In the following examples I'd just like to match the letters before the '=' M=A D=M MD=A A=D AD=M AMD=A I've come up with the following: ``` ([A-Z]{1,3})= ``` However this also matches the '=' which I don't want. I also tried: ``` ([A-Z^\=]{1,3})= ``` But I still have the same problem - it a matches the '=' sign as well. I'm using this site to test my regexes. Any help would be really appreciated. Thank you in advance.