Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

正規表現を使用し特定語句の前後に.*, .*|を挿入

More than 1 year has passed since last update.

Anacondaに、pyperclipをインストール

conda install -c conda-forge pyperclip

下記コードを実行

src = '''
以下の文字列を変更可能

 # -*- coding: utf-8 -*-
import pyperclip


src = pyperclip.paste()

src = '''ことば
supeinn
いぬ
ねこ
たぬき
きつね
'''
dest = ''
for s in src.splitlines():
    dest += '.*{}.*|'.format(s)

print(dest)# コンソール出力
pyperclip.copy(dest) # クリップボード出力
GmossP
webマーケ(SEO)、web制作(wordpress)などをやって来ました。 データ分析に興味があるのでPythonを勉強しています。 https://twitter.com/GmossP
https://twitter.com/GmossP
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away