这是字符串,一个完整的例子:
('1416851040', '1416851040', '50.62.177.118', '84.161.97.189', 'humpy_electro', 393883, '385962628'),
('1416851046', '1416851046', '2607:5300:60:6097::', '80.187.100.105', 'lagbugdc', 393884, '737537953'),
('1416851067', '1416851067', '174.66.174.101', '98.148.244.151', 'maihym', 393885, '1473193487'),
('1416851094', '1416851094', '2607:5300:60:6097::', '92.157.2.230', 'xeosse26', 393886, '737537953'),
我想从中移除-EVERYTHING-除了:facebook:jens.pettersson.7568
(用户名槽)
facebook:jens.pettersson.7568
实际上'facebook:jens.pettersson.7568'
的位置,我希望它显示为:
facebook:jens.pettersson.7568
(见那里的空白区域?)
然后对我的列表进行排序,其中所有361k行排列如下:
x x xx xcx xzx xyx xtz
所有空间,技术上1行,如果可能的话。
或者,如果删除并只收集我需要的1行就足够了,我可以手动进行排序,我猜想
答案 0 :(得分:0)
我会在两行之间阅读并猜测你想要的是:
BEFORE:
('1416851040', '1416851040', '50.62.177.118', '84.161.97.189', 'humpy_electro', 393883, '385962628'),
^ this is username
AFTER:
facebook:humpy_electro
您可以使用以下正则表达式处理:
s/(?:[^,]*,){4}[\s'"]*([^'",]*).*/facebook:$1, /
即
(?: # begin non-capturing group
[^,]*, # zero or more non-comma characters, followed by a comma
){4} # end non-capturing group, and repeat 4 times
# this skips the first 4 columns of data
[\s'"]* # matches any whitespace and the first quote
( # begin capturing group 1
[^'",]* # capture all non-comma characters until the end quote
) # end capturing group 1
.* # match rest of line
# REPLACE WITH
facebook: # literal text
$1 # capturing group 1
, # comma and a trailing space (not shown here)
瞧。
这转变了这个:
('1416851040', '1416851040', '50.62.177.118', '84.161.97.189', 'humpy_electro', 393883, '385962628'),
('1416851046', '1416851046', '2607:5300:60:6097::', '80.187.100.105', 'lagbugdc', 393884, '737537953'),
('1416851067', '1416851067', '174.66.174.101', '98.148.244.151', 'maihym', 393885, '1473193487'),
('1416851094', '1416851094', '2607:5300:60:6097::', '92.157.2.230', 'xeosse26', 393886, '737537953'),
进入这个
facebook:humpy_electro, facebook:lagbugdc, facebook:maihym, facebook:xeosse26,
答案 1 :(得分:-1)
我从朋友那里得到它,这是一个2部分:第一步:^((。?'){4})替换为什么,然后,第二步'((。?$){1})替换为空。