How can I Find/Replace part of a wildcard search in Notepad++
background, css, html, notepad++, regex
Solution
Change your search to something little less reliant on having one space (say you hit tab on one or two).
(background:.*?;)
And for your replace, use:
/* \1 */
What you were failing to do was to capture the matched value to reuse in your replace regex. The () in the search will store in a parameter which can be used as \1.
Problem
Simple Example. When I'm editing CSS. I want to Find all "backgrounds" regardless of the number sequence, so I'm using `.*` ~~~Example: Find `background: #.*;` (Found 4 Matches) Line12: background: #111111; Line24: background: #222222; Line36: background: #333333; Line48: background: #444444; "Found (#) of lines matching" Great, works perfect! (The next part is the where I'm having trouble) Now I want to Replace, or in this case wrap all these lines with /* */, without removing the individual numbers. (To remove certain backgrounds, when I'm done editing the page.) ~~~Example: Replace With `/* background: #.*; */` Doesn't give me this: Line12: /* background: #111111; */ Line24: /* background: #222222; */ Line36: /* background: #333333; */ Line48: /* background: #444444; */ Instead, it give me this: Line12: /* background: #.*; */ Line24: /* background: #.*; */ Line36: /* background: #.*; */ Line48: /* background: #.*; */ I can't figure out how to keep the numbers (regardless of the variety of combinations) from changing in the code and only add /* around the code */