我必须在文本文件中的-,=
后面但在推文开始之前删除任意数量的text:
或空格。到目前为止,我有这个想法。 text: ,|-|=|
这会占用多个空格,但也会删除整个文本文件中的所有空格。以下是一些示例文本。
posted: Sat Feb 03 2018 11:03:09 text: ,Today we can see positive trends for growth, but will there be a new fall? crypto screen_name: Ksandimo location: null verified: false followers_count: 1597 friends_count: 17 lang: ru retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:14 text: 8745.02$ per now screen_name: CoinLibre2009 location: Free World verified: false followers_count: 113 friends_count: 110 lang: ru retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:16 text: Current price of is $8745.02 screen_name: bitcoinavg location: null verified: false followers_count: 44 friends_count: 9 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:25 text: Think weve hit resistance for Bitcoin now. Will it fully recover? Im not sure screen_name: jasongaved location: Brighton & Hove / London verified: false followers_count: 1996 friends_count: 1967 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:28 text: Today's price is $8745.02 as of February 3, 2018 at 11:59AM screen_name: FR33Q location: Europe verified: false followers_count: 1164 friends_count: 1998 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:37 text: bitcoin might have been a hoax, the issue that the outrage was at these screen_name: krrishd_pzombie location: your mind verified: false followers_count: 28 friends_count: 12 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:50 text: =I believe the chart would be adoption of 'blockchain technology' rather than bitcoin individually... screen_name: mt_crypto location: null verified: false followers_count: 34 friends_count: 90 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:04:07 text: Current price of Bitcoin is $8745.02 via Chain screen_name: kimrin location: Kawasaki verified: false followers_count: 690 friends_count: 1012 lang: ja retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:04:14 text: -Compensation? Sounds interesting. Like 1 Bitcoin perhaps? Maybe a couple of Ethereum. Whatchu got in mind? screen_name: rahulsood location: seattle washington verified: true followers_count: 38820 friends_count: 2224 lang: en retweet_count: 0 favorite_count: 0
示例输出:
posted: Sat Feb 03 2018 11:03:09 text: Today we can see positive trends for growth, but will there be a new fall? crypto screen_name: Ksandimo location: null verified: false followers_count: 1597 friends_count: 17 lang: ru retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:14 text: 8745.02$ per now screen_name: CoinLibre2009 location: Free World verified: false followers_count: 113 friends_count: 110 lang: ru retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:16 text: Current price of is $8745.02 screen_name: bitcoinavg location: null verified: false followers_count: 44 friends_count: 9 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:25 text: Think weve hit resistance for Bitcoin now. Will it fully recover? Im not sure screen_name: jasongaved location: Brighton & Hove / London verified: false followers_count: 1996 friends_count: 1967 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:28 text: Today's price is $8745.02 as of February 3, 2018 at 11:59AM screen_name: FR33Q location: Europe verified: false followers_count: 1164 friends_count: 1998 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:37 text: bitcoin might have been a hoax, the issue that the outrage was at these screen_name: krrishd_pzombie location: your mind verified: false followers_count: 28 friends_count: 12 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:50 text: I believe the chart would be adoption of 'blockchain technology' rather than bitcoin individually... screen_name: mt_crypto location: null verified: false followers_count: 34 friends_count: 90 lang: en retweet_count: 0 favorite_count: 0
答案 0 :(得分:3)
查找:text:\s+[,=\s-]*
替换:text:
(末尾有一个空格)
改进的解决方案:
查找:(?<=^posted:\s[A-Z][a-z]{2}\s[A-Z][a-z]{2}\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\s{3})text:\s+[,=\s-]*
替换:text:
(末尾有一个空格)
改进的解决方案将避免在线上稍后出现的其他text:\s+[,=\s-]*
转换为text:
。
答案 1 :(得分:1)
答案 2 :(得分:1)
^.*?text:\h\K[-=,\h]+
LEAVE EMPTY
. matches newline
<强>解释强>
^ : beginning of line
.*? : 0 or more any character not greedy
text: : literally "text:"
\h : 1 horizontal space
\K : forget all we have seen until this position
[-=,\h]+ : 1 or more any of these character, dash, equal, comma or horizontal space
给定示例的结果:
posted: Sat Feb 03 2018 11:03:09 text: Today we can see positive trends for growth, but will there be a new fall? crypto screen_name: Ksandimo location: null verified: false followers_count: 1597 friends_count: 17 lang: ru retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:14 text: 8745.02$ per now screen_name: CoinLibre2009 location: Free World verified: false followers_count: 113 friends_count: 110 lang: ru retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:16 text: Current price of is $8745.02 screen_name: bitcoinavg location: null verified: false followers_count: 44 friends_count: 9 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:25 text: Think weve hit resistance for Bitcoin now. Will it fully recover? Im not sure screen_name: jasongaved location: Brighton & Hove / London verified: false followers_count: 1996 friends_count: 1967 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:28 text: Today's price is $8745.02 as of February 3, 2018 at 11:59AM screen_name: FR33Q location: Europe verified: false followers_count: 1164 friends_count: 1998 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:37 text: bitcoin might have been a hoax, the issue that the outrage was at these screen_name: krrishd_pzombie location: your mind verified: false followers_count: 28 friends_count: 12 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:03:50 text: I believe the chart would be adoption of 'blockchain technology' rather than bitcoin individually... screen_name: mt_crypto location: null verified: false followers_count: 34 friends_count: 90 lang: en retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:04:07 text: Current price of Bitcoin is $8745.02 via Chain screen_name: kimrin location: Kawasaki verified: false followers_count: 690 friends_count: 1012 lang: ja retweet_count: 0 favorite_count: 0
posted: Sat Feb 03 2018 11:04:14 text: Compensation? Sounds interesting. Like 1 Bitcoin perhaps? Maybe a couple of Ethereum. Whatchu got in mind? screen_name: rahulsood location: seattle washington verified: true followers_count: 38820 friends_count: 2224 lang: en retweet_count: 0 favorite_count: 0
答案 3 :(得分:0)
select regexp_replace(regexp_replace('posted: = Sat Feb 03 2018 11:03:50 text: =I believe - the chart would = be adoption of','.*text:','')
,',|-|=|\\s{2,}','')
\ s {2,}适用于多个空格
答案 4 :(得分:0)
试试replace(/,|-| |=/g, '')
。如果你想进一步删除空格,请从regx中减少一个空格。