@@ -2388,11 +2388,14 @@ msgid ""
2388
2388
"if match:\n"
2389
2389
" process(match)"
2390
2390
msgstr ""
2391
+ "correspondencia = re.search(padrao, string)\n"
2392
+ "if correspondencia:\n"
2393
+ " processa(correspondencia)"
2391
2394
2392
2395
#: ../../library/re.rst:1366
2393
2396
msgid "Match object returned by successful ``match``\\ es and ``search``\\ es."
2394
2397
msgstr ""
2395
- "Objetode correspondência retornado por ``match``\\ s e ``search``\\ s bem "
2398
+ "Objeto correspondência retornado por ``match``\\ s e ``search``\\ s bem "
2396
2399
"sucedidos."
2397
2400
2398
2401
#: ../../library/re.rst:1368
@@ -2459,6 +2462,15 @@ msgid ""
2459
2462
">>> m.group(1, 2) # Multiple arguments give us a tuple.\n"
2460
2463
"('Isaac', 'Newton')"
2461
2464
msgstr ""
2465
+ ">>> m = re.match(r\" (\\ w+) (\\ w+)\" ,\" Isaac Newton, físico\" )\n"
2466
+ ">>> m.group(0) # A correspondência inteira\n"
2467
+ "'Isaac Newton'\n"
2468
+ ">>> m.group(1) # O primeira subgrupo entre parênteses.\n"
2469
+ "'Isaac'\n"
2470
+ ">>> m.group(2) # O segundo subgrupo entre parênteses.\n"
2471
+ "'Newton'\n"
2472
+ ">>> m.group(1, 2) # Múltiplos argumentos retornam uma tupla.\n"
2473
+ "('Isaac', 'Newton')"
2462
2474
2463
2475
#: ../../library/re.rst:1409
2464
2476
msgid ""
@@ -2467,7 +2479,7 @@ msgid ""
2467
2479
"string argument is not used as a group name in the pattern, an :exc:"
2468
2480
"`IndexError` exception is raised."
2469
2481
msgstr ""
2470
- "Se a expressão regular usa a sintaxe ``(?P<name >...)``, os argumentos "
2482
+ "Se a expressão regular usa a sintaxe ``(?P<nome >...)``, os argumentos "
2471
2483
"*groupN* também podem ser strings que identificam grupos por seus nomes de "
2472
2484
"grupo. Se um argumento string não for usado como um nome de grupo no padrão, "
2473
2485
"uma exceção :exc:`IndexError` é levantada."
@@ -2485,6 +2497,12 @@ msgid ""
2485
2497
">>> m.group('last_name')\n"
2486
2498
"'Reynolds'"
2487
2499
msgstr ""
2500
+ ">>> m = re.match(r\" (?P<primeiro_nome>\\ w+) (?P<ultimo_nome>\\ w+)\" , "
2501
+ "\" Malcolm Reynolds\" )\n"
2502
+ ">>> m.group('primeiro_nome')\n"
2503
+ "'Malcolm'\n"
2504
+ ">>> m.group('ultimo_nome')\n"
2505
+ "'Reynolds'"
2488
2506
2489
2507
#: ../../library/re.rst:1422
2490
2508
msgid "Named groups can also be referred to by their index::"
@@ -2497,6 +2515,10 @@ msgid ""
2497
2515
">>> m.group(2)\n"
2498
2516
"'Reynolds'"
2499
2517
msgstr ""
2518
+ ">>> m.group(1)\n"
2519
+ "'Malcolm'\n"
2520
+ ">>> m.group(2)\n"
2521
+ "'Reynolds'"
2500
2522
2501
2523
#: ../../library/re.rst:1429
2502
2524
msgid "If a group matches multiple times, only the last match is accessible::"
@@ -2510,6 +2532,10 @@ msgid ""
2510
2532
">>> m.group(1) # Returns only the last match.\n"
2511
2533
"'c3'"
2512
2534
msgstr ""
2535
+ ">>> m = re.match(r\" (..)+\" ,\" a1b2c3\" ) # Corresponde 3 vezes.\n"
2536
+ ">>> m.group(1) # Retorna somente a última "
2537
+ "correspondência.\n"
2538
+ "'c3'"
2513
2539
2514
2540
#: ../../library/re.rst:1438
2515
2541
msgid ""
@@ -2529,10 +2555,17 @@ msgid ""
2529
2555
">>> m[2] # The second parenthesized subgroup.\n"
2530
2556
"'Newton'"
2531
2557
msgstr ""
2558
+ ">>> m = re.match(r\" (\\ w+) (\\ w+)\" ,\" Isaac Newton, físico\" )\n"
2559
+ ">>> m[0] # A correspondência inteira'\n"
2560
+ "Isaac Newton'\n"
2561
+ ">>> m[1] # O primeiro subgrupo entre parênteses.\n"
2562
+ "'Isaac'\n"
2563
+ ">>> m[2] # O segundo subgrupo entre parênteses.\n"
2564
+ "'Newton'"
2532
2565
2533
2566
#: ../../library/re.rst:1449
2534
2567
msgid "Named groups are supported as well::"
2535
- msgstr "Grupos nomeados também são suportados ::"
2568
+ msgstr "Também há suporte para grupos nomeados ::"
2536
2569
2537
2570
#: ../../library/re.rst:1451
2538
2571
msgid ""
@@ -2543,6 +2576,12 @@ msgid ""
2543
2576
">>> m['last_name']\n"
2544
2577
"'Newton'"
2545
2578
msgstr ""
2579
+ ">>> m = re.match(r\" (?P<primeiro_nome>\\ w+) (?P<segundo_nome>\\ w+)\" , "
2580
+ "\" Isaac Newton\" )\n"
2581
+ ">>> m['primeiro_nome']\n"
2582
+ "'Isaac'\n"
2583
+ ">>> m['segundo_nome']\n"
2584
+ "'Newton'"
2546
2585
2547
2586
#: ../../library/re.rst:1462
2548
2587
msgid ""
@@ -2564,6 +2603,9 @@ msgid ""
2564
2603
">>> m.groups()\n"
2565
2604
"('24', '1632')"
2566
2605
msgstr ""
2606
+ ">>> m = re.match(r\" (\\ d+)\\ .(\\ d+)\" ,\" 24.1632\" )\n"
2607
+ ">>> m.groups()\n"
2608
+ "('24', '1632')"
2567
2609
2568
2610
#: ../../library/re.rst:1472
2569
2611
msgid ""
@@ -2583,6 +2625,11 @@ msgid ""
2583
2625
">>> m.groups('0') # Now, the second group defaults to '0'.\n"
2584
2626
"('24', '0')"
2585
2627
msgstr ""
2628
+ ">>> m = re.match(r\" (\\ d+)\\ .?(\\ d+)?\" ,\" 24\" )\n"
2629
+ ">>> m.groups() # Segundo grupo padronizado para None.\n"
2630
+ "('24', None)\n"
2631
+ ">>> m.groups('0') # Agora, o segundo grupo é padronizado para '0'.\n"
2632
+ "('24', '0')"
2586
2633
2587
2634
#: ../../library/re.rst:1485
2588
2635
msgid ""
@@ -2602,6 +2649,10 @@ msgid ""
2602
2649
">>> m.groupdict()\n"
2603
2650
"{'first_name': 'Malcolm', 'last_name': 'Reynolds'}"
2604
2651
msgstr ""
2652
+ ">>> m = re.match(r\" (?P<primeiro_nome>\\ w+) (?P<segundo_nome>\\ w+)\" , "
2653
+ "\" Malcolm Reynolds\" )\n"
2654
+ ">>> m.groupdict()\n"
2655
+ "{'primeiro_nome': 'Malcolm', 'segundo_nome': 'Reynolds'}"
2605
2656
2606
2657
#: ../../library/re.rst:1497
2607
2658
msgid ""
@@ -2620,7 +2671,7 @@ msgstr ""
2620
2671
2621
2672
#: ../../library/re.rst:1503
2622
2673
msgid "m.string[m.start(g):m.end(g)]"
2623
- msgstr ""
2674
+ msgstr "m.string[m.start(g):m.end(g)] "
2624
2675
2625
2676
#: ../../library/re.rst:1505
2626
2677
msgid ""
@@ -2636,7 +2687,7 @@ msgstr ""
2636
2687
2637
2688
#: ../../library/re.rst:1510
2638
2689
msgid "An example that will remove *remove_this* from email addresses::"
2639
- msgstr "Um exemplo que removerá *remove_this * dos endereços de e-mail::"
2690
+ msgstr "Um exemplo que removerá *remova_isto * dos endereços de e-mail::"
2640
2691
2641
2692
#: ../../library/re.rst:1512
2642
2693
msgid ""
@@ -2645,16 +2696,21 @@ msgid ""
2645
2696
">>> email[:m.start()] + email[m.end():]\n"
2646
2697
"'tony@tiger.net'"
2647
2698
msgstr ""
2699
+ ">>> email =\" tony@tiremova_istoger.net\" \n"
2700
+ ">>> m = re.search(\" remova_isto\" , email)\n"
2701
+ ">>> email[:m.start()] + email[m.end():]\n"
2702
+ "'tony@tiger.net'"
2648
2703
2649
2704
#: ../../library/re.rst:1520
2650
2705
msgid ""
2651
2706
"For a match *m*, return the 2-tuple ``(m.start(group), m.end(group))``. Note "
2652
2707
"that if *group* did not contribute to the match, this is ``(-1, -1)``. "
2653
2708
"*group* defaults to zero, the entire match."
2654
2709
msgstr ""
2655
- "Para uma correspondência *m*, retorna a tupla de dois ``(m.start(group), m."
2656
- "end(group))``. Observe que se *group* não contribuiu para a correspondência, "
2657
- "isso é ``(-1, -1)``. *group* tem como padrão zero, a correspondência inteira."
2710
+ "Para uma correspondência *m*, retorna a tupla com dois elementos ``(m."
2711
+ "start(group), m.end(group))``. Observe que se *group* não contribuiu para a "
2712
+ "correspondência, isso é ``(-1, -1)``. *group* tem como padrão zero, a "
2713
+ "correspondência inteira."
2658
2714
2659
2715
#: ../../library/re.rst:1527
2660
2716
msgid ""
@@ -2663,8 +2719,8 @@ msgid ""
2663
2719
"index into the string at which the RE engine started looking for a match."
2664
2720
msgstr ""
2665
2721
"O valor de *pos* que foi passado para o método :meth:`~Pattern.search` ou :"
2666
- "meth:`~Pattern.match` de um :ref:`objetode regex <re-objects>`. Este é o "
2667
- "índice da string na qual o mecanismo de ER começou a procurar uma "
2722
+ "meth:`~Pattern.match` de um :ref:`objetoexpressão regular <re-objects>`. "
2723
+ "Este é o índice da string na qual o mecanismo de ER começou a procurar uma "
2668
2724
"correspondência."
2669
2725
2670
2726
#: ../../library/re.rst:1534
@@ -2674,8 +2730,9 @@ msgid ""
2674
2730
"the index into the string beyond which the RE engine will not go."
2675
2731
msgstr ""
2676
2732
"O valor de *endpos* que foi passado para o método :meth:`~Pattern.search` "
2677
- "ou :meth:`~Pattern.match` de um :ref:`objeto de regex <re-objects>`. Este é "
2678
- "o índice da string após o qual o mecanismo de ER não vai chegar."
2733
+ "ou :meth:`~Pattern.match` de um :ref:`objeto expressão regular <re-"
2734
+ "objects>`. Este é o índice da string após o qual o mecanismo de ER não vai "
2735
+ "chegar."
2679
2736
2680
2737
#: ../../library/re.rst:1541
2681
2738
msgid ""
@@ -2717,7 +2774,7 @@ msgid ""
2717
2774
"Added support of :func:`copy.copy` and :func:`copy.deepcopy`. Match objects "
2718
2775
"are considered atomic."
2719
2776
msgstr ""
2720
- "Adicionado suportede :func:`copy.copy` e :func:`copy.deepcopy`. Objetos "
2777
+ "Adicionado suportepara :func:`copy.copy` e :func:`copy.deepcopy`. Objetos "
2721
2778
"correspondência são considerados atômicos."
2722
2779
2723
2780
#: ../../library/re.rst:1573