The goal is to implement a lexer for the C / 8 # if / else construct, decided to implement it by successively passing the input line through regexps, which I started to deal with recently. When writing regexps for constants / variables, I use non-capture groups before and after a capture group to adequately recognize lexemes, but the problem is that if the matches of non-capture groups match, the value on the right is not recognized. If you remove a group without capture in front of the main group, all values are recognized. For example, without the first test group: 
This is only observed at the junction of matches: 
That is, as can be seen from the example, in the else block, the intermediate value n is not highlighted, because it is located at the “junction”.
The expression itself (with all groups):
/(?:[-+*\/=<>{)(;]{1})([A-Za-z]{1}[A-Za-z0-9]*)(?:[-;+*\/=<>)]{1})/ Line:
if(dsf==35){x=y/10;}else{y=n/25+n;} What should be changed in order to pass the test and at the same time recognize all the desired lexemes (in this case, variables)?
UPD: problem with analysis solved, implementation of parsing remained 
Code of patterns, if anyone is interested (on the left is a token, on the right is its indices in the input line):
public static Dictionary<string, string> Patterns = new Dictionary<string, string>() { {"variable", @"(?:[-+*\/=<>{)(;]{1})([A-Za-z]{1}[A-Za-z0-9]*)"}, {"operator", @"(?:[A-Za-z0-9]+?)([<>]{1}[=]?|[=]{2}|!{1}={1}|[-+*\/=]+?)"}, {"punctuation", @"([)({};]+?)"}, {"keyword", @"(if|else)(?:[({]+?)"}, {"constante", @"(?:[-+*\/=<>(]+?)([-]?[\d]+[.]?[\d]*)"} }; Link to regex101 with the edited expression, maybe you will have more comments:

if's to begin with. - VladDelse if if x > < > if = else, and issue to the outside the tokensELSE IF IF IDENT(x) GT LT GT IF EQ ELSE. That is, it should not “recognize the if / else construct, but simply recognize the tokensIFandELSE. - VladD