Search code examples
regexnotepad++

How do I change only the <LNK:XXX> with localhost, leaving the rest of the block as is?


I wanted to change the below LNK:XXX to 'localhost', leaving everything else as is. From this:

$FLD  tcp:<LNK:FLD>+<PORT>|<ACCOUNT>|<PASSWORD>|fsvr
$SVC  tcp:<LNK:SVC>+<PORT>|<ACCOUNT>|<PASSWORD>|rsvr
$SRV  tcp:<LNK:SRV>+<PORT>|<ACCOUNT>|<PASSWORD>|ysvr
$DOC  tcp:<LNK:DOC>+<PORT>|<ACCOUNT>|<PASSWORD>|dsvr
$XSL  tcp:<LNK:XSL>+<PORT>|<ACCOUNT>|<PASSWORD>|xsvr
$XSD  tcp:<LNK:XSD>+<PORT>|<ACCOUNT>|<PASSWORD>|xsvr
$PDF  tcp:<LNK:PDF>+<PORT>|<ACCOUNT>|<PASSWORD>|asvr
$EML  tcp:<LNK:EML>+<PORT>|<ACCOUNT>|<PASSWORD>|esvr
$BBD  tcp:<LNK:BBD>+<PORT>|<ACCOUNT>|<PASSWORD>|bsvr
$DEW  tcp:<LNK:DEW>+<PORT>|<ACCOUNT>|<PASSWORD>|dwsvr
$JAR  tcp:<LNK:JAR>+<PORT>|<ACCOUNT>|<PASSWORD>|jsvr
$DUT  tcp:<LNK:DUT>+<PORT>|<ACCOUNT>|<PASSWORD>|hsvr
$SUP  tcp:<LNK:SUP>+<PORT>|<ACCOUNT>|<PASSWORD>|susvr

To this:

$FLD  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|fsvr
$SVC  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|rsvr
$SRV  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|ysvr
$DOC  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|dsvr
$XSL  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|xsvr
$XSD  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|xsvr
$PDF  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|asvr
$EML  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|esvr
$BBD  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|bsvr
$DEW  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|dwsvr
$JAR  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|jsvr
$DUT  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|hsvr
$SUP  tcp:localhost+<PORT>|<ACCOUNT>|<PASSWORD>|susvr

I tried LNK:.* but this matches the entire line.


Solution

  • You need

    Find What: <LNK:[^>]*>
    Replace With: localhost

    See the regex demo. Details:

    • <LNK: - a literal <LNK: string
    • [^>]* - zero or more chars other than >
    • > - a literal > char.

    enter image description here