I'm new to regex and I want to highlight hexadecimal numbers in Assembly style. Like this:
and even hexadecimal numbers that begin with #.
So far I wrote "$[A-Fa-f0-9]+" to see if it highlights numbers beginning with $ but it doesn't. Why? And can someone help me with what I'm doing? Thanks.
Put a back slash before $ and your regex will work like so
$ is a valid regex character that matches with end of string. So if your pattern contains dollar then you need to escape it. See regex reference for details
This should cover all those cases, including the cases in which you get a # instead of a $
public Regex MyRegex = new Regex( "^(\\()?[\\$#][0-9a-fA-F]+(,x)?(?(1)\\))[\\s]*$", RegexOptions.Singleline | RegexOptions.Compiled );
The unescaped sequence for the single line:
That should validate on a per-line match.
By the way, I made this regex pretty quickly using Expresso