Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pythonで正規表現にマッチする文字列をランダムに生成する ref: http://qiita.com/yubessy/items/6df954f3ad1806c17fdd
$ pip install rstr
>>> import rstr
>>> rstr.xeger(r'[0-9a-zA-Z0-9]+') # 英数字
'4ihgj8nNmGIr88yCxeR366kU05biWc4dYUsjvPQoAyF11gPG4T85UnSsp6PS8'
>>> rstr.xeger(r'[あーヴ]+') # ひらがな・カタカナ
'かざきうたいえさまぎょざちぅゐえほでれのすぇがゅせけかなぇぼぉつぅでぽちゆきぴび'
>>> rstr.digits(), rstr.word(), rstr.nonword() # 便利メソッドいくつか
('330624228', 'J0xDw0zmZ', '@[\",\t|];')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment