Notepad++ - Delete Everything Other Than The Specified Strings

2

I have the following strings that I want to keep and delete the rests: uicomp-type="example-string" uicomp-type='string-example'

I use the following regex to find those strings:

uicomp-type="(.*?)"|uicomp-type='(.*?)'

How to select the strings other than those I want to keep or what's the opposite of the regex above?

I mean like NOT uicomp-type="(.*?)"|uicomp-type='(.*?)'

EDIT:

Example data set:

"Div box"    => '<div uicomp-type='div-stndalone' class="ddasset-div-box"></div>',
                                        "HTML Code"  => '<div uicomp-type='div-code' class="ddasset-html-box"></div>',
                                        "Shortcode"  => '<div uicomp-type="shortcode" class="ddasset-shortcode-box"><input uicomp-type="input-shortcode" type="text" name="" value="" class="shortcodepreviewer" placeholder="Insert your shortcode here!"/></div>',
                                        "Features list"      => '<ul uicomp-type="ul" class="adtdd_ul">
                                                        <li uicomp-type="li"><i uicomp-type="icon" class="mif-checkmark"></i> <dx uicomp-type="text" class="dxeditable"> Features item 1</dx></li>
                                                        <li uicomp-type="li"><i uicomp-type="icon" class="mif-checkmark"></i> <dx uicomp-type="text" class="dxeditable"> Features item 2</dx></li>
                                                        <li uicomp-type="li"><i uicomp-type="icon" class="mif-checkmark"></i> <dx uicomp-type="text" class="dxeditable"> Features item 3</dx></li>
                                                        <li uicomp-type="li"><i uicomp-type="icon" class="mif-checkmark"></i> <dx uicomp-type="text" class="dxeditable"> Features item 4</dx></li>
                                                        <li uicomp-type="li"><i uicomp-type="icon" class="mif-checkmark"></i> <dx uicomp-type="text" class="dxeditable"> Features item 5</dx></li>
                                                        <div class="clear"></div>
                                                        </ul>',
                                        "Separator"  => '<div uicomp-type="div" class="adt-dd-separator adt-dd-separator-k"><hr uicomp-type="hr-separator"></div>',
                                        "Badges/ ribbon"  => '<div uicomp-type="null" class="dd-ribbon">
                                                            <div uicomp-type="div-ribbon" class="dd-ribbon-inner"><span uicomp-type="text" class="dxeditable">POPULAR</span></div>
                                                            </div>',

Ari

Posted 2015-07-08T19:48:53.347

Reputation: 121

1Should be possible with a negative lookaround (?!), but can't get it to click. The pattern could be shortened to uicomp-type=["'](.*?)["'] btw. – bertieb – 2015-07-08T20:46:59.827

I had tried to use (?!) and there is no luck! – Ari – 2015-07-08T20:52:33.400

I think it can be done, but my regex-fu is weak. (?!.*uicomp-type=["'].*?["']) is the closest I've got; but it returns a whole bunch of useless zero-length matches too. Feel like I'm missing something obvious! – bertieb – 2015-07-08T20:58:23.653

Haven't given up on this- do you have a small set of example data to test on? Might be able to narrow it down. – bertieb – 2015-07-10T09:25:06.050

adding the example as you requested! – Ari – 2015-07-10T17:27:02.087

Answers

0

Not pure regex, but a quick macro can copy all instances to a second tab. NP++ macros are awsome, but a couple quirks add a bit of a creativity requirement.

  1. <Record>
  2. F3 (Find next)
  3. Ctrl-X (Can't copy because of a quirk causing the cursor position to reset)
  4. Ctrl-2 (Switch to other (empty) tab)
  5. Ctrl-End (Again, cursor is lost)
  6. Ctrl-V (Paste in new tab)
  7. Enter (Add a line for the next one)
  8. Ctrl-1 (Move back to document)
  9. <Stop>

Then, in the find window, click "Count" which in your example returned 25 instances. So you can "Run a Macro Multiple Times" (25).

Chad Schouggins

Posted 2015-07-08T19:48:53.347

Reputation: 101