4

Usually I have the following situation: There is a PONO class with list of the properties.

    public string UserName
    {
        get { return this.userName; }
        set { if (this.userName != value) { SetDirty(); this.userName = value; } }
    }

    public string Password
    {
        get { return this.password; }
        set { if (this.password != value) { SetDirty(); this.password = value; } }
    }

    public string Email
    {
        get { return this.email; }
        set { if (this.email != value) { SetDirty(); this.email = value; } }
    }

    public string Title
    {
        get { return this.title; }
        set { if (this.title != value) { SetDirty(); this.title = value; } }
    }

Is there are tool, preferably Notepad++ or VS plugin, to extract the regex output into another file?

For example: Find: "public string (.*)$" results:

UserName
Password
Email
Title

in a new file.

ikutsin
  • 1,118
  • 15
  • 22

2 Answers2

7

In Notepad++ use Search/Find dialog and in Mark tab check the Bookmark line checkbox - after Mark all you will have bookmarks on all desired lines. enter image description here

The last step is Search/Bookmark/Copy bookmarked lines and paste them in a new file, where you can remove the public string part.

From v5.8.7 changelog:

  • In order to reduce the confusion, new "Mark" tab for "Mark all" feature is made in Find/Replace dialog.

I guess that the Bookmark line checkbox and Mark all are placed in another tab in v5.8.6.

alexandrul
  • 12,856
  • 13
  • 72
  • 99
  • I don't have "Mark" tab in Find dialog. Notepad++ v5.8.6 with default plugins. – ikutsin Mar 18 '11 at 11:00
  • 1
    in Notepad++ v5.8.6 there is a checkbox on the Find tab for this feature, but I would recommend to update Notepad. – stema Mar 18 '11 at 11:17
  • You can also strip out the "public string" part while within notepad++. After Mark all, do Search/Bookmark/Remove unmarked lines. Then go back to the Find/Replace. Click the Replace tab and (while using the original search string shown) put \1 in the replace string. Then press replace all. – RufusVS Sep 18 '14 at 18:01
1

Not a text editor solution, but

grep "public string .+$" < file | sed "s/public string (.+)$/\1/" > out

should work. Untested.

alternative
  • 12,703
  • 5
  • 41
  • 41