• Login
Community
  • Login

Help with finding prefixes & selecting entire string

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 3 Posters 356 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    Miska Virtanen
    last edited by Apr 19, 2023, 11:13 PM

    Hello!

    I just wanted to ask, if there was a relatively simple way to find the prefix to a string, and automatically highlight the entire string with Find & Replace. What I’m trying to do is mass edit CSV files. The strings are separated by commas.
    Let’s say a file has data like this;
    bb_1234,aa_1233,cb_1244

    If I wanted to find all the strings starting with “bb_”, and highlight & replace the entire string, up until the next comma. So replacing the bb_ prefix data with something like ZZZ should make the data appear as;
    ZZZ,aa_1233,cb_1244

    Thank you in advance!

    T 1 Reply Last reply Apr 19, 2023, 11:18 PM Reply Quote 0
    • T
      Terry R @Miska Virtanen
      last edited by Terry R Apr 20, 2023, 12:05 AM Apr 19, 2023, 11:18 PM

      @Miska-Virtanen said in Help with finding prefixes & selecting entire string:

      If I wanted to find all the strings starting with “bb_”, and highlight & replace the entire string, up until the next comma.

      That can be done simply with a regular expression (regex). Using the Replace function you would have
      Find What:\bbb_[^,]+
      Replace With:ZZZ
      Search mode must be set to regular expression.

      It didn’t sound as if it was only at the start of a line, hence my regex will look for that sequence in any “cell”. If this isn’t what you actually wanted you will need to elaborate.

      Terry

      P 1 Reply Last reply Jun 7, 2023, 7:28 PM Reply Quote 5
      • P
        Pool Strip @Terry R
        last edited by Jun 7, 2023, 7:28 PM

        Terry-R said in Help with finding prefixes & selecting entire string:

        @Miska-Virtanen said in Help with finding prefixes & selecting entire string:

        If I wanted to find all the strings starting with “bb_”, and highlight & replace the entire string, up until the next comma.

        That can be done simply with a regular expression (regex). Using the Replace function you would have
        Find What:\bbb_[^,]+
        Replace With:ZZZ
        Search mode must be set to regular expression.

        It didn’t sound as if it was only at the start of a line, hence my regex will look for that sequence in any “cell”. If this isn’t what you actually wanted you will need to elaborate.

        Terry

        Thanks.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors