I need to insert a prefix in a hexadecimal string before every 2 characters.
My first thought was using lookaround like
(?=[0-9a-f]{2})but obviously it won't work because it finds every position that has two symbols after, not every other position.
The line is:
d0bfd0bed181d182d183d0bfd0b8d0bbd0beI can use (?=d[01]) and (?<=d[01]) because the line contains only lowercase cyrillic letters but if possible I need a more universal solution.
Another problem is that Atom editor, as it seems, can't insert anything in a negative space found by a working lookaround expression. Replacement works with position regexes like ^ or $ but not with lookarond/lookbehind expressions.
If it cannot be done in Atom please recommend a good code&text editor for Mac OS that understands perl flavour regex for editing.
CodePudding user response:
You can use
([0-9a-f]{2})
and replace with <your_prefix>$1
to add a prefix to the matched string.
Unfortunately, there is no support for $0
backreference in Atom, so you will have to use an outer capturing group round the whole pattern.