我知道我是个白痴,但我不能从这个电子邮件地址中删除该域名:
'blahblah@gmail.com'
Run Code Online (Sandbox Code Playgroud)
我想要的输出:
'@gmail.com'
Run Code Online (Sandbox Code Playgroud)
我目前的输出:
.
Run Code Online (Sandbox Code Playgroud)
(这只是一个时期角色)
这是我的代码:
import re
test_string = 'blahblah@gmail.com'
domain = re.search('@*?\.', test_string)
print domain.group()
Run Code Online (Sandbox Code Playgroud)
这是我认为我的正则表达式('@*?.',test_string):
' # begin to define the pattern I'm looking for (also tell python this is a string)
@ # find all patterns beginning with the at symbol ("@")
* # find all characters after ampersand
? # find the last character before the period
\ # breakout (don't use the next character as a wild card, us it is a …Run Code Online (Sandbox Code Playgroud) 我有一个目录(目录A),其中包含10,000个文件.我想将其中一些移动到目录B,其他移动到目录C.我创建了一个文本文件,其中包含我要移动到目录B的所有文件的名称,另一个文件包含我想要的所有文件的名称移动到目录C.如何编写bash for循环以将这些文件移动到新目录.
伪代码:
对于textfileB中的文件:
将文件从目录A移动到目录B
对于textfileC中的文件:
将文件从目录A移动到目录C
对不起,如果这是在其他地方被问到,但我花了好几个小时试图学习bash而我却没有得到它.我无法在另一个我能理解的线程中找到类似的东西(也许我只是不知道正确的搜索词).
我有这样的东西,但我无法让它工作:
FILES=[dont' know what goes here? An array? A list?
Run Code Online (Sandbox Code Playgroud)
我可以只说明文本文件名,如果是,那么文件必须是什么格式?name1.ext,name2.ext或name1.ext name2.ext]
for f in $FILES; do mv $f /B/$f [not sure about the second argument for mv]; done
Run Code Online (Sandbox Code Playgroud)
谢谢
BTW Mac OSX 10.6.8(Snow Leopard)Apple Terminal v.2.1.2/273.1 Bash 3.2