regexnotepad++tilde

How to Match Tilde-Delimited Data Using Regex


I have data like this:

~10~682423~15~Test Data~10~68276127~15~More Data~10~6813~15~Also Data~

I'm trying to use Notepad++ to find and replace the values within tag 10 (682423, 68276127, 6813) with zeroes. I thought the syntax below would work, but it selects the first occurrence of the text I want and the rest of the line, instead of just the text I want (~10~682423~, for example). I also tried dozens of variations from searching online, but they also either did the same thing or wouldn't return any results.

~10~.*~

Solution

  • Use

    \b10~\d+
    

    Replace with 10~0. See proof. \b10~ will capture 10 as entire number (no match in 210 is allowed) and \d+ will match one or more digits.