Replacing some regex-matched text with some text containing literal escape characters fails
Ubuntu 18.10 gedit 3.28.1
I'm trying to replace some recurring text using a regular expression with the same literal regex. For instance, in the following 2 lines, I need to replace all characters up to the ']' with the same replacement regex:
Find Regex:
^\w{3} [ :[:digit:]]{11}[._[:alnum:]-]+ kernel:( \[ *[[:digit:]]+\.[[:digit:]]+\])?
Replace with literal Regex:
^\\w{3} [ :[:digit:]]{11}[._[:alnum:]-]+ kernel:( \\[ *[[:digit:]]+\\.[[:digit:]]+\\])?
For instance, if we start with the following "Source text", gedit fails to obtain the following "Replaced text".
Source text:
Aug 1 09:33:49 samsung4-ubuntu kernel: [ 0.045109] pinctrl core: initialized pinctrl subsystem
Aug 1 09:33:50 samsung4-ubuntu kernel: [ 0.172476] Bluetooth: Core ver 2.22
Replaced text:
^\w{3} [ :[:digit:]]{11}[._[:alnum:]-]+ kernel:( \[ *[[:digit:]]+\.[[:digit:]]+\])? pinctrl core: initialized pinctrl subsystem
^\w{3} [ :[:digit:]]{11}[._[:alnum:]-]+ kernel:( \[ *[[:digit:]]+\.[[:digit:]]+\])? Bluetooth: Core ver 2.22
It also fails if I replace the regexes with the following simpler ones:
Find Regex:
^[a-zA-Z]{3} [ :0-9]{11}[._a-zA-Z0-9-]+ kernel: \[ *[0-9]+\.[0-9]+\]
Replace with literal Regex:
^[a-zA-Z]{3} [ :0-9]{11}[._a-zA-Z0-9-]+ kernel: \\[ *[0-9]+\\.[0-9]+\\]