@@ -954,9 +954,9 @@ msgstr ""
954954"p = re.compile( ... )\n"
955955"m = p.search( 'string goes here' )\n"
956956"if m:\n"
957- "print('Match found: ', m.group())\n"
957+ " print('Match found: ', m.group())\n"
958958"else:\n"
959- "print('No match')"
959+ " print('No match')"
960960
961961msgid ""
962962"Two pattern methods return all of the matches for a pattern. :meth:`~re."
@@ -1012,7 +1012,7 @@ msgstr ""
10121012">>> iterator\n"
10131013"<callable_iterator object at 0x...>\n"
10141014">>> for match in iterator:\n"
1015- "... print(match.span())\n"
1015+ "... print(match.span())\n"
10161016"...\n"
10171017"(0, 2)\n"
10181018"(22, 24)\n"
@@ -1285,13 +1285,13 @@ msgid ""
12851285"\"\"\" , re.VERBOSE)"
12861286msgstr ""
12871287"charref = re.compile(r\"\"\" \n"
1288- "&[#] # Start of a numeric entity reference\n"
1289- "(\n"
1290- "0[0-7]+ # Octal form\n"
1291- "| [0-9]+ # Decimal form\n"
1292- "| x[0-9a-fA-F]+ # Hexadecimal form\n"
1293- ")\n"
1294- "; # Trailing semicolon\n"
1288+ " &[#] # Start of a numeric entity reference\n"
1289+ " (\n"
1290+ " 0[0-7]+ # Octal form\n"
1291+ " | [0-9]+ # Decimal form\n"
1292+ " | x[0-9a-fA-F]+ # Hexadecimal form\n"
1293+ " )\n"
1294+ " ; # Trailing semicolon\n"
12951295"\"\"\" , re.VERBOSE)"
12961296
12971297msgid "Without the verbose setting, the RE would look like this::"
@@ -1303,8 +1303,8 @@ msgid ""
13031303" \" |x[0-9a-fA-F]+);\" )"
13041304msgstr ""
13051305"charref = re.compile(\" &#(0[0-7]+\" \n"
1306- "\" |[0-9]+\" \n"
1307- "\" |x[0-9a-fA-F]+);\" )"
1306+ " \" |[0-9]+\" \n"
1307+ " \" |x[0-9a-fA-F]+);\" )"
13081308
13091309msgid ""
13101310"In the above example, Python's automatic concatenation of string literals "
@@ -1926,11 +1926,11 @@ msgid ""
19261926" r'\" ')"
19271927msgstr ""
19281928"InternalDate = re.compile(r'INTERNALDATE \" '\n"
1929- "r'(?P<day>[ 123][0-9])-(?P<mon>[A-Z][a-z][a-z])-'\n"
1930- "r'(?P<year>[0-9][0-9][0-9][0-9])'\n"
1931- "r' (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9])'\n"
1932- "r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'\n"
1933- "r'\" ')"
1929+ " r'(?P<day>[ 123][0-9])-(?P<mon>[A-Z][a-z][a-z])-'\n"
1930+ " r'(?P<year>[0-9][0-9][0-9][0-9])'\n"
1931+ " r' (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9])'\n"
1932+ " r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'\n"
1933+ " r'\" ')"
19341934
19351935msgid ""
19361936"It's obviously much easier to retrieve ``m.group('zonem')``, instead of "
@@ -2305,11 +2305,11 @@ msgid ""
23052305">>> p.sub('colour', 'blue socks and red shoes', count=1)\n"
23062306"'colour socks and red shoes'"
23072307msgstr ""
2308- "\" >>> p = re.compile('(blue|white|red)')\\ n \" \n"
2309- "\" >>> p.sub('colour', 'blue socks and red shoes')\\ n \" \n"
2310- "\" 'colour socks and colour shoes'\\ n \" \n"
2311- "\" >>> p.sub('colour', 'blue socks and red shoes', count=1)\\ n \" \n"
2312- "\" 'colour socks and red shoes'\" "
2308+ ">>> p = re.compile('(blue|white|red)')\n"
2309+ ">>> p.sub('colour', 'blue socks and red shoes')\n"
2310+ "'colour socks and colour shoes'\n"
2311+ ">>> p.sub('colour', 'blue socks and red shoes', count=1)\n"
2312+ "'colour socks and red shoes'"
23132313
23142314msgid ""
23152315"The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-"
@@ -2326,11 +2326,11 @@ msgid ""
23262326">>> p.subn('colour', 'no colours at all')\n"
23272327"('no colours at all', 0)"
23282328msgstr ""
2329- "\" >>> p = re.compile('(blue|white|red)')\\ n \" \n"
2330- "\" >>> p.subn('colour', 'blue socks and red shoes')\\ n \" \n"
2331- "\" ('colour socks and colour shoes', 2)\\ n \" \n"
2332- "\" >>> p.subn('colour', 'no colours at all')\\ n \" \n"
2333- "\" ('no colours at all', 0)\" "
2329+ ">>> p = re.compile('(blue|white|red)')\n"
2330+ ">>> p.subn('colour', 'blue socks and red shoes')\n"
2331+ "('colour socks and colour shoes', 2)\n"
2332+ ">>> p.subn('colour', 'no colours at all')\n"
2333+ "('no colours at all', 0)"
23342334
23352335msgid ""
23362336"Empty matches are replaced only when they're not adjacent to a previous "
@@ -2403,13 +2403,13 @@ msgid ""
24032403">>> p.sub(r'subsection{\\ g<name>}','section{First}')\n"
24042404"'subsection{First}'"
24052405msgstr ""
2406- "\" >>> p = re.compile('section{ (?P<name> [^}]* ) }', re.VERBOSE)\\ n \" \n"
2407- "\" >>> p.sub(r'subsection{\\\\ 1}','section{First}')\\ n \" \n"
2408- "\" 'subsection{First}'\\ n \" \n"
2409- "\" >>> p.sub(r'subsection{\\\\ g<1>}','section{First}')\\ n \" \n"
2410- "\" 'subsection{First}'\\ n \" \n"
2411- "\" >>> p.sub(r'subsection{\\\\ g<name>}','section{First}')\\ n \" \n"
2412- "\" 'subsection{First}'\" "
2406+ ">>> p = re.compile('section{ (?P<name> [^}]* ) }', re.VERBOSE)\n"
2407+ ">>> p.sub(r'subsection{\\ 1}','section{First}')\n"
2408+ "'subsection{First}'\n"
2409+ ">>> p.sub(r'subsection{\\ g<1>}','section{First}')\n"
2410+ "'subsection{First}'\n"
2411+ ">>> p.sub(r'subsection{\\ g<name>}','section{First}')\n"
2412+ "'subsection{First}'"
24132413
24142414msgid ""
24152415"*replacement* can also be a function, which gives you even more control. If "
@@ -2441,9 +2441,9 @@ msgid ""
24412441"'Call 0xffd2 for printing, 0xc000 for user code.'"
24422442msgstr ""
24432443">>> def hexrepl(match):\n"
2444- "... \" Return the hex string for a decimal number\" \n"
2445- "... value = int(match.group())\n"
2446- "... return hex(value)\n"
2444+ "... \" Return the hex string for a decimal number\" \n"
2445+ "... value = int(match.group())\n"
2446+ "... return hex(value)\n"
24472447"...\n"
24482448">>> p = re.compile(r'\\ d+')\n"
24492449">>> p.sub(hexrepl, 'Call 65490 for printing, 49152 for user code.')\n"
@@ -2618,13 +2618,13 @@ msgid ""
26182618">>> print(re.prefixmatch('<.*>', s).group())\n"
26192619"<html><head><title>Title</title>"
26202620msgstr ""
2621- "\" >>> s = '<html><head><title>Title</title>'\\ n \" \n"
2622- "\" >>> len(s)\\ n \" \n"
2623- "\" 32 \\ n \" \n"
2624- "\" >>> print(re.prefixmatch('<.*>', s).span())\\ n \" \n"
2625- "\" (0, 32)\\ n \" \n"
2626- "\" >>> print(re.prefixmatch('<.*>', s).group())\\ n \" \n"
2627- "\" <html><head><title>Title</title>\" "
2621+ ">>> s = '<html><head><title>Title</title>'\n"
2622+ ">>> len(s)\n"
2623+ "32 \n"
2624+ ">>> print(re.prefixmatch('<.*>', s).span())\n"
2625+ "(0, 32)\n"
2626+ ">>> print(re.prefixmatch('<.*>', s).group())\n"
2627+ "<html><head><title>Title</title>"
26282628
26292629msgid ""
26302630"The RE matches the ``'<'`` in ``'<html>'``, and the ``.*`` consumes the rest "
@@ -2657,8 +2657,8 @@ msgid ""
26572657">>> print(re.prefixmatch('<.*?>', s).group())\n"
26582658"<html>"
26592659msgstr ""
2660- "\" >>> print(re.prefixmatch('<.*?>', s).group())\\ n \" \n"
2661- "\" <html>\" "
2660+ ">>> print(re.prefixmatch('<.*?>', s).group())\n"
2661+ "<html>"
26622662
26632663msgid ""
26642664"(Note that parsing HTML or XML with regular expressions is painful. Quick-"
@@ -2722,22 +2722,20 @@ msgid ""
27222722" \\ s*$ # Trailing whitespace to end-of-line\n"
27232723"\"\"\" , re.VERBOSE)"
27242724msgstr ""
2725- "\" pat = re.compile(r\\\"\\\"\\\"\\ n \" \n"
2726- "\" \\\\ s* # Skip leading whitespace\\ n \" \n"
2727- "\" (?P<header>[^:]+) # Header name\\ n \" \n"
2728- "\" \\\\ s* : # Whitespace, and a colon\\ n \" \n"
2729- "\" (?P<value>.*?) # The header's value -- *? used to\\ n \" \n"
2730- "\" # lose the following trailing whitespace\\ n \" \n"
2731- "\" \\\\ s*$ # Trailing whitespace to end-of-line\\ n \" \n"
2732- "\"\\\"\\\"\\\" , re.VERBOSE)\" "
2725+ "pat = re.compile(r\"\" \" \n"
2726+ " \\ s* # Skip leading whitespace\n"
2727+ " (?P<header>[^:]+) # Header name\n"
2728+ " \\ s* : # Whitespace, and a colon\n"
2729+ " (?P<value>.*?) # The header's value -- *? used to\n"
2730+ " # lose the following trailing whitespace\n"
2731+ " \\ s*$ # Trailing whitespace to end-of-line\n"
2732+ "\"\"\" , re.VERBOSE)"
27332733
27342734msgid "This is far more readable than::"
27352735msgstr "ਇਹ ਹੇਠਾਂ ਦਿੱਤੀ ਐਕਸਪ੍ਰੈਸ਼ਨ ਨਾਲੋਂ ਕਾਫ਼ੀ ਵੱਧ ਪੜ੍ਹਨਯੋਗ ਹੈ:"
27362736
27372737msgid "pat = re.compile(r\"\\ s*(?P<header>[^:]+)\\ s*:(?P<value>.*?)\\ s*$\" )"
2738- msgstr ""
2739- "\" pat = re.compile(r\\\"\\\\ s*(?P<header>[^:]+)\\\\ s*:(?P<value>.*?)\\\\ s*$\\ "
2740- "\" )\" "
2738+ msgstr "pat = re.compile(r\"\\ s*(?P<header>[^:]+)\\ s*:(?P<value>.*?)\\ s*$\" )"
27412739
27422740msgid "Feedback"
27432741msgstr "ਫੀਡਬੈਕ"
0 commit comments