Sample Header Ad - 728x90

How to replace a line in text using RegEX?

1 vote
3 answers
917 views
The problem I have is that is trying to match both sets of delimiter (above and below) **I'm trying to match only the second part of the delimiter below (bolded).** enter image description here **This is so I can add a new version made on the same day to multiple files. Using perl, so I can get a result like this when I make the replacement** enter image description here **How ever according to https://regex101.com/ (and my experience when I ran the command) it selects both sets of delimiters,** enter image description here **making a replacement above and below.** enter image description here This is the RegEx I'm using (?!V[0-9]{2}.[0-9]{2}.[0-9]{4}.1)(.*=.$) And the comand in UNIX: perl -pe 's#(?!V[0-9]{2}.[0-9]{2}.[0-9]{4}.1)(.*=.$)#-* V02.11.2020.1 11/Feb/2020 Author2 Minor Changed Include lms \n -* ================ ============= ==================== =========== ========================================================/#g' path/to/file Is there a way to select the one below? Or the problem originates from the Negative Lookahead? -********************************************************************** EDIT I used the command selected by bey0nd 3,$s/ -\* =[=[:space:]]*\// -* V02.11.2020.1\t 11\/Feb\/2020\t Author2\t\t Minor\tChange include 1ms\n\0/1 It helped a lot with readability But I'm still getting both delimeters (= signs) repalced. I thought that the lookaround function of regex would've helped enter image description here **I'm using perl 5 and sed 4.2** At least I got it to work in regex101.com, but in my version didn't work Hope someone finds it useful (-\* =[=[:space:]]*\/)(?!\n.-\*[[:space:]].V[0-9]{2}.[0-9]{2}.[0-9]{4}.1*)
Asked by Javier Vazquez (11 rep)
Feb 12, 2020, 12:55 AM
Last activity: Feb 13, 2020, 11:46 AM