\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{mutanclan (mutanclan)} \pdfinfo{ /Title (python-regular-expression-regex.pdf) /Creator (Cheatography) /Author (mutanclan (mutanclan)) /Subject (python regular expression (regex) Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{176E0D} \definecolor{LightBackground}{HTML}{F7FAF7} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{python regular expression (regex) Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{mutanclan (mutanclan)} via \textcolor{DarkBackground}{\uline{cheatography.com/79625/cs/19404/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}mutanclan (mutanclan) \\ \uline{cheatography.com/mutanclan} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 19th April, 2019.\\ Updated 25th February, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{1.14471 cm} x{3.83229 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Special characters}} \tn % Row 0 \SetRowColor{LightBackground} . & Default: Match any character except newline \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} . & DOTALL: Match any character including newline \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \textasciicircum{} & Default: Match the start of a string \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \textasciicircum{} & MULTILINE: Match immediatly after each newline \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \$ & Match the end of a string \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} \$ & MULTILINE: Also match before a newline \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} * & Match 0 or more repetitions of RE \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} + & Match 1 or more repetitions of RE \tn % Row Count 15 (+ 2) % Row 8 \SetRowColor{LightBackground} ? & Match 0 or 1 repetitions of RE \tn % Row Count 16 (+ 1) % Row 9 \SetRowColor{white} *?, *+, ?? & Match non-greedy as {\emph{few}} characters as possible \tn % Row Count 18 (+ 2) % Row 10 \SetRowColor{LightBackground} \{m\} & Match exactly {\emph{m}} copies of the previous RE \tn % Row Count 20 (+ 2) % Row 11 \SetRowColor{white} \{m,n\} & Match from {\emph{m}} to {\emph{n}} repetitions of RE \tn % Row Count 22 (+ 2) % Row 12 \SetRowColor{LightBackground} \{m,n\}? & Match non-greedy \tn % Row Count 23 (+ 1) % Row 13 \SetRowColor{white} \textbackslash{} & Escape special characters \tn % Row Count 24 (+ 1) % Row 14 \SetRowColor{LightBackground} {[}{]} & Match a {\emph{set}} of characters \tn % Row Count 25 (+ 1) % Row 15 \SetRowColor{white} | & {\emph{RE1}}|{\emph{RE2}}: Match either RE1 {\emph{or}} RE2 non-greedy \tn % Row Count 27 (+ 2) % Row 16 \SetRowColor{LightBackground} (...) & Match RE inside parantheses and indicate start and end of a group \tn % Row Count 30 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{With RE is the resulting regular expression.\{\{nl\}\} \newline Special characters must be escaped with \textbackslash{} if it should match the character literally} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Methods of 're' module}} \tn % Row 0 \SetRowColor{LightBackground} re.{\bf{compile}}(\{\{nl\}\}{\emph{pattern}},\{\{nl\}\}{\emph{flags=0}}) & Compile a regular expression pattern into a regular expression object. Can be used with {\emph{match()}}, {\emph{search()}} and others \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} re.{\bf{search}}(\{\{nl\}\}{\emph{pattern}},\{\{nl\}\}{\emph{string}},\{\{nl\}\}{\emph{flags=0}} & Search through {\emph{string}} matching the first location of the RE. Returns a {\bf{match object}} or {\bf{None}} \tn % Row Count 12 (+ 6) % Row 2 \SetRowColor{LightBackground} re.{\bf{match}}(\{\{nl\}\}{\emph{pattern}},\{\{nl\}\}{\emph{string}},\{\{nl\}\}{\emph{flags=0}}) & If zero or more characters at the beginning of a string match {\emph{pattern}} return a {\bf{match object}} or {\bf{None}} \tn % Row Count 18 (+ 6) % Row 3 \SetRowColor{white} re.{\bf{fullmatch}}(\{\{nl\}\}{\emph{pattern}},\{\{nl\}\}{\emph{string}},\{\{nl\}\}{\emph{flags=0}}) & If the whole {\emph{string}} matches the {\emph{pattern}} return a {\bf{match object}} or {\bf{None}} \tn % Row Count 23 (+ 5) % Row 4 \SetRowColor{LightBackground} re.{\bf{split}}(\{\{nl\}\}{\emph{pattern}},\{\{nl\}\}{\emph{string}},\{\{nl\}\}{\emph{maxsplit=0}},\{\{nl\}\}{\emph{flags=0}}) & Split {\emph{string}} by the occurrences of {\emph{pattern}} {\emph{maxsplit}} times if non-zero. Returns a {\bf{list}} of all groups. \tn % Row Count 29 (+ 6) % Row 5 \SetRowColor{white} re.{\bf{findall}}(\{\{nl\}\}{\emph{pattern,\{\{nl\}\}string,\{\{nl\}\}flags=0}}) & Return all non-overlapping matches of {\emph{pattern}} in {\emph{string}} as {\bf{list}} of strings. \tn % Row Count 34 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Methods of 're' module (cont)}} \tn % Row 6 \SetRowColor{LightBackground} re.{\bf{finditer}}(\{\{nl\}\}{\emph{pattern,\{\{nl\}\}string,\{\{nl\}\}flags=0}}) & Return an {\bf{iterator}} yielding {\bf{match objects}} over all non-overlapping matches for the {\emph{pattern}} in {\emph{string}} \tn % Row Count 6 (+ 6) % Row 7 \SetRowColor{white} re.{\bf{sub}}(\{\{nl\}\}{\emph{pattern,\{\{nl\}\}repl,\{\{nl\}\}string,\{\{nl\}\}count=0,\{\{nl\}\}flags=0}}) & Return the {\bf{string}} obtained by replacing the leftmost non-overlapping occurrences of {\emph{pattern}} in {\emph{string}} by the {\emph{replacement}} {\emph{repl}}. {\emph{repl}} can be a function. \tn % Row Count 15 (+ 9) % Row 8 \SetRowColor{LightBackground} re.{\bf{subn}}(\{\{nl\}\}{\emph{pattern,\{\{nl\}\}repl,\{\{nl\}\}string,\{\{nl\}\}count=0,\{\{nl\}\}flags=0}}) & \{\{noshy\}\}Like {\bf{sub}} but return a tuple ({\emph{new\_string}}, {\emph{number\_of\_subs\_made}}) \tn % Row Count 19 (+ 4) % Row 9 \SetRowColor{white} re.{\bf{escape}}(\{\{nl\}\}{\emph{pattern}}) & Escape special characters in {\emph{pattern}} \tn % Row Count 21 (+ 2) % Row 10 \SetRowColor{LightBackground} re.{\bf{purge}}() & Clear the regular expression cache \tn % Row Count 23 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Raw String Notation}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{In raw string notation `r"text"` there is no need to escape the backslash character again. \newline % Row Count 2 (+ 2) `\textgreater{}\textgreater{}\textgreater{} re.match(r"\textbackslash{}W(.)\textbackslash{}1\textbackslash{}W", " ff ")` \newline % Row Count 3 (+ 1) `\textless{}re.Match object; span=(0, 4), match=' ff '\textgreater{}` \newline % Row Count 4 (+ 1) `\textgreater{}\textgreater{}\textgreater{} re.match("\textbackslash{}\textbackslash{}W(.)\textbackslash{}\textbackslash{}1\textbackslash{}\textbackslash{}W", " ff ")` \newline % Row Count 5 (+ 1) `\textless{}re.Match object; span=(0, 4), match=' ff '\textgreater{}`% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Reference}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{https://docs.python.org/3/howto/regex.html}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{https://docs.python.org/3/library/re.html}} \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Extensions}} \tn % Row 0 \SetRowColor{LightBackground} (?...) & This is the start of an extension \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} (?aiLmsux) & The letters set the correspondig flags {\emph{See flags}} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} (?:...) & A non-capturing version of regular parantheses \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} (?P\textless{}name\textgreater{}...) & Like regular paranthes but with a {\emph{named}} group \tn % Row Count 11 (+ 3) % Row 4 \SetRowColor{LightBackground} (?P=name) & A backreference to a {\emph{named}} group \tn % Row Count 13 (+ 2) % Row 5 \SetRowColor{white} (?\#...) & A comment \tn % Row Count 14 (+ 1) % Row 6 \SetRowColor{LightBackground} (?=...) & {\emph{lookahead assertion}}: Matches if {\bf{...}} matches next without consuming the string \tn % Row Count 19 (+ 5) % Row 7 \SetRowColor{white} (?!...) & {\emph{negative lookahead assertion}}: Matches if {\bf{...}} doesn't match next \tn % Row Count 23 (+ 4) % Row 8 \SetRowColor{LightBackground} (?\textless{}=....) & {\emph{positive lookbehind assertion}}: Match if the current position in the string is preceded by a match for {\bf{...}} that ends the current position \tn % Row Count 31 (+ 8) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Extensions (cont)}} \tn % Row 9 \SetRowColor{LightBackground} (?\textless{}!...) & {\emph{negative lookbehind assertion}}: Match if the current position in the string is {\bf{not}} preceded by a match for {\bf{...}} \tn % Row Count 6 (+ 6) % Row 10 \SetRowColor{white} \{\{noshy\}\}(?(id/name)yes-pattern|no-pattern) & Match with {\emph{yes-pattern}} if the group with gived {\emph{id}} or {\emph{name}} exists and with {\emph{no-pattern}} if not \tn % Row Count 11 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Match objects}} \tn % Row 0 \SetRowColor{LightBackground} Match.{\bf{expand}}(\{\{nl\}\}{\emph{template}}) & Return the string obtained by doing backslash substitution on {\emph{template}}, as done by the {\bf{sub()}} method \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} Match.{\bf{group}}(\{\{nl\}\}{\bf{{[}}}{\emph{group1}},...{\bf{{]}}}) & Returns one or more subgroups of the match. 1 Argument returns {\bf{string}} and more arguments return a {\bf{tuple}}. \tn % Row Count 12 (+ 6) % Row 2 \SetRowColor{LightBackground} Match.{\bf{\_\_getitem\_\_}}(\{\{nl\}\}{\emph{g}}) & Access groups with m{[}0{]}, m{[}1{]} ... \tn % Row Count 14 (+ 2) % Row 3 \SetRowColor{white} Match.{\bf{groups}}(\{\{nl\}\}{\emph{default=None}}) & Return a {\bf{tuple}} containing all the subgroups of the match \tn % Row Count 17 (+ 3) % Row 4 \SetRowColor{LightBackground} Match.{\bf{groupdict}}(\{\{nl\}\}{\emph{default=None}}) & Return a {\bf{dictionary}} containing all the {\emph{named}} subgroups of the match, keyed by the subgroup name. \tn % Row Count 23 (+ 6) % Row 5 \SetRowColor{white} Match.{\bf{start}}(\{\{nl\}\}{\bf{{[}}}{\emph{group{\bf{}}{]}}}\{\{nl\}\}Match.{\bf{end}}(\{\{nl\}\}{\bf{{[}}}{\emph{group{\bf{}}{]}}}) & Return the indices of the start and end of the substring matched by {\emph{group}} \tn % Row Count 28 (+ 5) % Row 6 \SetRowColor{LightBackground} Match.{\bf{span}}(\{\{nl\}\}{\bf{{[}}}{\emph{group{\bf{}}{]}}}) & \{\{noshy\}\}For a match {\emph{m}}, return the 2-tuple `(m.start(group) m.end(group))` \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Match objects (cont)}} \tn % Row 7 \SetRowColor{LightBackground} Match.{\bf{pos}} & The value of {\emph{pos}} which was passed to the {\bf{search()}} or {\bf{match()}} method of the {\bf{regex object}} \tn % Row Count 6 (+ 6) % Row 8 \SetRowColor{white} Match.{\bf{endpos}} & Likewise but the value of {\emph{endpos}} \tn % Row Count 8 (+ 2) % Row 9 \SetRowColor{LightBackground} Match.{\bf{lastindex}} & The integer index of the last matched capturing group, or `None`. \tn % Row Count 12 (+ 4) % Row 10 \SetRowColor{white} Match.{\bf{lastgroup}} & The name of the last matched capturing group or `None` \tn % Row Count 15 (+ 3) % Row 11 \SetRowColor{LightBackground} Match.{\bf{re}} & The {\bf{regular expression object}} whose {\bf{match()}} or {\bf{search()}} method produced this match instance \tn % Row Count 21 (+ 6) % Row 12 \SetRowColor{white} Match.{\bf{string}} & The string passed to {\bf{match()}} or {\bf{search()}} \tn % Row Count 24 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Special escape characters}} \tn % Row 0 \SetRowColor{LightBackground} \textbackslash{}A & Match only at the start of the string \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \textbackslash{}b & Match the empty string at the beginning or end of a word \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \textbackslash{}B & Match the empty string when {\emph{not}} at the beginning or end of a word \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \textbackslash{}d & Match any {\bf{Unicode}} decimal digit this includes {[}0-9{]} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \textbackslash{}D & Match any character which is {\bf{not}} a decimal digit \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \textbackslash{}s & Match {\bf{Unicode}} white space characters which includes {[} \textbackslash{}t\textbackslash{}n\textbackslash{}r\textbackslash{}f\textbackslash{}v{]} \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} \textbackslash{}S & Matches any character which is {\bf{not}} a whitespace character. The opposite of \textbackslash{}s \tn % Row Count 15 (+ 3) % Row 7 \SetRowColor{white} \textbackslash{}w & Match {\bf{Unicode}} word characters including {[}a-zA-Z0-9\_{]} \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} \textbackslash{}W & Match the opposite of \textbackslash{}w \tn % Row Count 18 (+ 1) % Row 9 \SetRowColor{white} \textbackslash{}Z & Match only at the end of a string \tn % Row Count 19 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Regular Expression Objects}} \tn % Row 0 \SetRowColor{LightBackground} Pattern.{\bf{search}}(\{\{nl\}\}{\emph{string{\bf{}}{[}}},\{\{nl\}\}{\emph{pos{\bf{}}{[}}},\{\{nl\}\}{\emph{endpos{\bf{}}{]}{]}}}) & See `re.{\bf{search()}}`. {\emph{pos}} gives an index where to start the search. {\emph{endpos}} limits how far the string will be searched. \tn % Row Count 7 (+ 7) % Row 1 \SetRowColor{white} Pattern.{\bf{match}}(\{\{nl\}\}{\emph{string{\bf{}}{[}}},\{\{nl\}\}{\emph{pos{\bf{}}{[}}},\{\{nl\}\}{\emph{endpos{\bf{}}{]}{]}}}) & Likewise but see `re.{\bf{match()}}` \tn % Row Count 11 (+ 4) % Row 2 \SetRowColor{LightBackground} Pattern.{\bf{fullmatch}}(\{\{nl\}\}{\emph{string{\bf{}}{[}}},\{\{nl\}\}{\emph{pos{\bf{}}{[}}},\{\{nl\}\}{\emph{endpos{\bf{}}{]}{]}}}) & Likewise but see `re.{\bf{fullmatch()}}` \tn % Row Count 15 (+ 4) % Row 3 \SetRowColor{white} Pattern.{\bf{split}}(\{\{nl\}\}{\emph{string,\{\{nl\}\}maxsplit=0}}) & Identical to `re.{\bf{split()}}` \tn % Row Count 18 (+ 3) % Row 4 \SetRowColor{LightBackground} Pattern.{\bf{findall}}(\{\{nl\}\}{\emph{string{\bf{}}{[}}},\{\{nl\}\}{\emph{pos{\bf{}}{[}}},\{\{nl\}\}{\emph{endpos{\bf{}}{]}{]}}}) & Similar to `re.{\bf{findall()}}` but with additional parameters {\emph{pos}} and {\emph{endpos}} \tn % Row Count 22 (+ 4) % Row 5 \SetRowColor{white} Pattern.{\bf{finditer}}(\{\{nl\}\}{\emph{string{\bf{}}{[}}},\{\{nl\}\}{\emph{pos{\bf{}}{[}}},\{\{nl\}\}{\emph{endpos{\bf{}}{]}{]}}}) & Similar to `re.{\bf{finditer()}}` but with additional parameters {\emph{pos}} and {\emph{endpos}} \tn % Row Count 26 (+ 4) % Row 6 \SetRowColor{LightBackground} Pattern.{\bf{sub}}(\{\{nl\}\}{\emph{repl,\{\{nl\}\}string,\{\{nl\}\}count=0}}) & Identical to `re.{\bf{sub()}}` \tn % Row Count 29 (+ 3) % Row 7 \SetRowColor{white} Pattern.{\bf{subn}}(\{\{nl\}\}{\emph{repl,\{\{nl\}\}string,\{\{nl\}\}count=0}}) & Identical to `re.{\bf{subn()}}` \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Regular Expression Objects (cont)}} \tn % Row 8 \SetRowColor{LightBackground} Pattern.{\bf{flags}} & The regex matching flags. \tn % Row Count 2 (+ 2) % Row 9 \SetRowColor{white} Pattern.{\bf{groups}} & The number of capturing groups in the pattern \tn % Row Count 5 (+ 3) % Row 10 \SetRowColor{LightBackground} \{\{noshy\}\}Pattern.{\bf{groupindex}} & A dictionary mapping any symbolic group names to group members \tn % Row Count 9 (+ 4) % Row 11 \SetRowColor{white} Pattern.{\bf{pattern}} & The pattern string from which the pattern object was compiled \tn % Row Count 13 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{These objects are returned by the `re.{\bf{compile()}}` method} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Flags}} \tn % Row 0 \SetRowColor{LightBackground} \{\{nobreak\}\}ASCII, A & ASCII-only matching in \textbackslash{}w, \textbackslash{}b, \textbackslash{}s and \textbackslash{}d \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \{\{nobreak\}\}IGNORECASE, I & ignore case \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}LOCALE, L & do a local-aware match \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \{\{nobreak\}\}MULTILINE, M & multiline matching, affecting `\textasciicircum{}` and `\$` \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \{\{nobreak\}\}DOTALL, S & dot matches all \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} u & unicode matching (just in (?aiLmsux)) \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} \{\{nobreak\}\}VERBOSE, X & verbose \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\{\{noshy\}\}Flags are used in (?aiLmsux-imsx:...) or (?aiLmsux) or can be accessed with re.{\bf{FLAG}}. In the first form flags are set or removed.\{\{nl\}\} \newline 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} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}