正規表現 python vs shellscript
置換表現
問題1
内容1
以下のメールアドレスを一括で置換したい
'[email protected] [email protected] [email protected]'
↓
[email protected] [email protected] [email protected]
python.py
s = '[email protected] [email protected] [email protected]'
print(re.sub('[a-z]*@', 'ABC@', s))
shell.sh
# mail.text に'[email protected] [email protected] [email protected]'を記入して
# その1
sed -e "s/*@/ABC@/g" mail.txt
# その2
sed -e "s/[a-z]*@/ABC@/g" mail.txt
問題2
内容2
以下の「文章」を単語区切りにしたい.
'Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.'
python.py
str = 'Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.'
# ,と.を除去
str = re.sub('[,\.]', '', str)
shell.sh
# memo.textに「文章」を記入して
sed -e "s/\.//g" -e "s/\,//g" memo.txt
Author And Source
この問題について(正規表現 python vs shellscript), 我々は、より多くの情報をここで見つけました https://qiita.com/aAyakaYamamoto/items/cf66710b7ac0ade74405著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .