2012-11-30 69 views
1

文本清潔制我有一個微博的文件,它包含了這樣的臺詞:用記事本++

RichardJ0nes -- Should I upgrade to an iPhone 5? Decisions, decisions! 
AnthonyMOliva -- @AnthonyMOliva AT&T offering iPhone 5 refurbished starting at $99: Two months after making its debut, refur... http://t.co/IsPDzIrD #BBC 
mittrashi -- RT @timesofindia: Apple iPhone 5S, iPad 5 already in the works? - The Times of India http://t.co/s782BHp5 

我想清理這個文件。 首先我想清除用戶名(例如:RichardJ0nes - 或@AnthonyMOliva),其次我想清除鏈接(例如http://t.co/s782BHp5)。

它應該是這樣的:

Should I upgrade to an iPhone 5? Decisions, decisions! 
AT&T offering iPhone 5 refurbished starting at $99: Two months after making its debut, refur... 
Apple iPhone 5S, iPad 5 already in the works? - The Times of India 

我嘗試做與記事本正則表達式++的東西,但我無法清除文本

我嘗試先刪除用戶名與
找到.*\(--\) 更換:\1

但它不能在記事本++。我該怎麼做,請給我一個想法?

回答

6

搜索(^\S+\s--|\bhttps?://\S+|(?:^|(?<=\s))[@#]\S+)\s?並將其替換爲空字符串。

+0

也許在'[@#]'之前加上'(?:RT)?'以匹配它。 – garyh

+0

@garyh - 我相信OP想要保持這一點,即使他/她的問題顯示沒有。否則,關於搜索/替換規則的問題還不清楚...... –

+0

我同意,OP並不清楚,因爲他們沒有明確聲明刪除「RT」,但是它並未出現在已清除的文本中。只是增加價值! – garyh

2

在記事本+按ctrl+f,去替代選項卡,並在底部你搜索模式選擇正則表達式然後執行以下操作

  1. 搜索:.* -- (.*)$並更換所有\1
  2. 搜索:@[^ ]*並全部替換爲空(將替換輸入留空)
  3. 搜索:http[^ ]* d全部替換爲空(將替換輸入留空)