2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Regex

Last updated at Posted at 2014-08-29

#something about regular expression

regarding compile

same meaning.

  • with compile
.py
prog = re.compile(pattern)
result = prog.match(string)
  • without compile
.py
result = re.match(pattern, string)

If you want to check the regex instantly, use
reg tester.

##Example for reminder
###time with timezone.

1999-04-13 15:00:00+09:00
.re
^\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}\+\d{2}:\d{2}$
^\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}(\+|\-)\d{2}:\d{2}$

###number expression.

2999.5982
.re
^[0-9]+$ # integer, only number no unicode number

^\d+\.\d+$ # real number, number and unicode number

^[-]?¥d+(¥.¥d+)?$ #real, plus/minus, number and unicode
^[-]?[0-9]+(¥.[0-9]+)?$ #real, plus/minus only number,

##special character requiring escape.

, *, +, ., ?, {}, (), [], ^, $, -, |, /

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?