Skip to content

Instantly share code, notes, and snippets.

@nwiizo
Created May 11, 2016 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwiizo/af076fb5b837a726dd834eb27d6c61c6 to your computer and use it in GitHub Desktop.
Save nwiizo/af076fb5b837a726dd834eb27d6c61c6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
m = re.compile(r"\[\[File\:(?P<p1>.+?)\|.+\]\]|\[\[ファイル\:(?P<p2>.+?)\|.+\]\]")
#得にコメントなし
#[File:*] or [ファイル:*]でマッチさせる。
#(?P<name>.+?)はテンプレ
with open("data02","rt") as f:
for l in f:
if m.match(l):
m_1 = m.search(l)
#m.serch(m,l)と同義
if m_1.group("p1"):
print(m_1.group("p1"))
if m_1.group("p2"):
print(m_1.group("p2"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment