0

I have a lot of text like this in Notepad ++:

User Actions 
 Follow
Online Marketing
@LookSocialMedia
Talk about #socialmedia, #SEO, online marketing, affiliate sales, #SMO, #PPC and much more. Join the discussion.


User Actions 
Following
Mashable Verified account
@mashable
News, resources, inspiration and fun for the connected generation. Tweets by @mashable staff.

I would like to extract all twitter handles - get a unique list like this:

@mashable  
@LookSocialMedia

all Twitter user profiles in one list.

What is the best way to extract those usernames and have unique list of them in one doc?

3 Answers 3

2

One option is to use the bookmarks within Notepad++.

Search for:

^@.*$

Within Mark, checking Bookmark line and Regular Expression (but not . matches newline)

enter image description here


Click Search -> Bookmark -> Remove unmarked lines

enter image description here


You should be left with the following:

enter image description here

1

I'd use a stepwise approach:

  1. save your file to a new location, you'll remove unwanted content from there
  2. To remove all non username content:
  3. to remove duplicates :
    • replace all (\@[^@]+)(.*)\1
    • to \1\2
  4. and finally to get one username per line:
    • replace all (\@[^@]+)
    • to \1\n
0

This will generate a new file in the same directory as the current file, adding a ".sorted" between the original file name and extension.

In Notepad++ while displaying your input file, hit F5 then paste the following in:

powershell -command "get-content '$(FULL_CURRENT_PATH)' | select-string -list -pattern '^@' | sort-object" > "$(CURRENT_DIRECTORY)\$(NAME_PART).sorted.$(EXT_PART)"

Note that this will overwrite an existing file if present.

Run or save the command. Saving will allow you to assign a key combo shortcut. Someone with better PowerShell-fu than I may want to chime in on an easy way to strip the leading blank line in the output file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .