Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regular expression \Z(?ms)

Tags:

python

regex

What does \Z(?ms) mean in a regular expression?

\Z is end-of-string, but what is the (?ms) part?

This is added by fnmatch.translate("abc") to the returned regular expression.

like image 601
Ksh Padalkar Avatar asked Aug 17 '12 01:08

Ksh Padalkar


1 Answers

From the docs:

(?iLmsux)

(One or more letters from the set 'i', 'L', 'm', 's', 'u', 'x'.) The group matches the empty string; the letters set the corresponding flags: re.I (ignore case), re.L (locale dependent), re.M (multi-line), re.S (dot matches all), re.U (Unicode dependent), and re.X (verbose), for the entire regular expression. (The flags are described in Module Contents.) This is useful if you wish to include the flags as part of the regular expression, instead of passing a flag argument to the re.compile() function.

like image 63
Ignacio Vazquez-Abrams Avatar answered Sep 29 '22 07:09

Ignacio Vazquez-Abrams