LoginSignup
3
3

More than 5 years have passed since last update.

めざせpythonライブラリマスター (28)verbalexpressions

Posted at

【ライブラリ説明】

 難しい正規表現を取り扱いやすくします

【プログラム】

verbalexpressions.py
# -*- coding: utf-8 -*-

from verbalexpressions import VerEx
verbal_expression = VerEx()

tester = (verbal_expression.
            start_of_line().
            find('http').
            maybe('s').
            find('://').
            maybe('www.').
            anything_but(' ').
            end_of_line()
)

test_url = "https://www.google.com"

if tester.match(test_url):
    print "Valid URL"
    # Valid URL

print tester.source()
# ^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$

【参考サイト】

 pypi
 github

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3