I would like to insert multiple of lines from a text file before a particular text. I would like to use regex to select the particular text, and the text is like this:
//**insert_yannyann*//
『//**insert_yannyann*//』is in b.txt, and b.txt is just like that
...
//**insert_yannyann*//
...
a.txt is like that:
1234
5678
9101
For inserting a.txt text file before the pattern of text in b.txt , I tried this regex in ubuntu 18.04 bash command.
sed -n -i -e '\/\/**insert_yannyann*\/\/ /r a.txt' -e 1x -e '2,${x;p}' -e '${x;p}' b.txt
even I tried another regex pattern.
sed -n -i -e '//?\s*\*[(?=.*\insert_yannyann\b)]*?\*\s*//? /r a.txt' -e 1x -e '2,${x;p}' -e '${x;p}' b.txt
but sed always show wrong message to me for the wrong regex I used.
I want to make b.txt be like that:
...
1234
5678
9101
//**insert_yannyann*//
...
I am certainly check two of these regex is correct by some online regex tools, but I don't understand why sed show wrong message to me.
\/\/**insert_yannyann*\/\/
//?\s*\*[(?=.*\insert_yannyann\b)]*?\*\s*//?
I'm not sure whether regex regulation is the same in different programming languages, could somebody explain why it is not correct?