0

I want to change some text but not digits

<img src=“BISM1281.png” id=“Image3” alt="">
<img src=“BISM1282.png” id=“Image3” alt="">
<img src=“BISM1283.png” id=“Image3” alt="">
to
<img src=“101BISM1281.png” id=“Image3” alt="">
<img src=“101BISM1282.png” id=“Image3” alt="">
<img src=“101BISM1283.png” id=“Image3” alt="">

I want to add some text or numbers before BISM, but don't want to change anything after BISM. Cannot use simple search and replace because “img src=“BISM” is using in different locations.

7
  • Replace BISM with 101BISM? "... because “img src=“BISM” is using in different locations" What's wrong with that?
    – 41686d6564
    Commented Aug 6, 2021 at 11:21
  • And how can we distinguish the locations that must not be changed?
    – RubioRic
    Commented Aug 6, 2021 at 11:24
  • can be distinguish with "id=“Image3” alt" , only change BISM that has image3 tag.
    – Sheraz
    Commented Aug 6, 2021 at 11:26
  • Note that in your examples you have and for attributes - I hope in reality they are " like in alt="" at the end of your lines. Commented Aug 6, 2021 at 11:30
  • Yes @PeterKrebs they are simple html coding
    – Sheraz
    Commented Aug 6, 2021 at 11:33

1 Answer 1

2
  • Ctrl+H
  • Find what: src="\K(?=BISM.+?id="Image3")
  • Replace with: 101
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

src="               # literally
\K                  # forget all we have seen until this position
(?=                 # positive lookahead, make sure we have after:
    BISM                # literally
    .+?                 # 1 or more any character but newline
    id="Image3"         # literally
)                   # end lookahead

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

1
  • 1
    @DroidReaders: You're welcome, glad it helps. Feel free to mark the answer as accepted, How to accept an answer
    – Toto
    Commented Aug 6, 2021 at 13:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.