Dylan_Larkin Dylan_Larkin - 3 months ago 29
C++ Question

simple regex seemingly not working c++

Trying to find a regex to indicate whether the right side of an equation has an 'M' or not. This is what I have:


Here's how I translate this:

^ - assert start of line

[everything in brackets] - match one or more characters NOT in these brackets

(?==) - positive lookahead... but now that I'm actually writing this out I think this might be the error.

I've been developing my regex's on www.regex101.com on the php default (I know, dumb, but I can't find an online C++ version). It's just hard to predict the behavior doing it this way, and when I have something that seems like it would work, it only partially works.


M=D-M // should indicate M on RHS
D=D+A // should not indicate M on RHS
D=A // should not indicate M on RHS

It's possible my code has a subtle bug not related to the Regex, but I'm pretty sure that's not the case. It works for dozens of cases with only 2-3 errors. Let's assume its related to regex.

P.S. I'm trying to parse some simple .asm files...



Try this regex:


Demo here: