Pattern doesn't respect ^ or $ - ([^%w]|^)(\d*\.\d+|\dx[\da-fA-F]*|\d+)([^%w]|$)

I’ve been trying to make a pattern which handles all sorts of numbers and highlight them in a certain color. However, the pattern I’ve been trying to make does not work because of anchor characters I actually need to use.

([^%w]|^)(\d*\.\d+|\dx[\da-fA-F]*|\d+)([^%w]|$)

I can tell where it’s coming from, and it’s specifically the two groups from either side and their ^ and & anchor characters. However, these anchors are extremely important, as they are used as exceptions for when a number happens to exist at the beginning and/or end of a string.

So far I haven’t found a way to substitute the anchors effectively.

1 Like