-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathregex.po
More file actions
1454 lines (1117 loc) · 150 KB
/
Copy pathregex.po
File metadata and controls
1454 lines (1117 loc) · 150 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Alireza Shabani (Revisto) <theRevisto@gmail.com>, 2025
# Danial Behzadi <dani.behzi@ubuntu.com>, 2025
# Rafael Fontenelle <rffontenelle@gmail.com>, 2025
# Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-09-16 12:56+0000\n"
"PO-Revision-Date: 2026-09-13 07:16+0330\n"
"Last-Translator: Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026\n"
"Language-Team: Persian (https://github.com/python/python-docs-fa/fa/)\n"
"Language: fa\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.6\n"
msgid "Regular expression HOWTO"
msgstr "راهنمای عبارت باقاعده"
msgid "Author"
msgstr "نویسنده"
msgid "A.M. Kuchling <amk@amk.ca>"
msgstr "A.M. Kuchling <amk@amk.ca>"
msgid "Abstract"
msgstr "چکیده"
msgid "This document is an introductory tutorial to using regular expressions in Python with the :mod:`re` module. It provides a gentler introduction than the corresponding section in the Library Reference."
msgstr "این سند آموزشی مقدماتی برای استفاده از عبارات باقاعده در پایتون با ماژول :mod:`re` است. این سند در مقایسه با بخش متناظر در مرجع کتابخانه، مقدمهای سادهتر ارائه میدهد."
msgid "Introduction"
msgstr "مقدمه"
msgid "Regular expressions (called REs, or regexes, or regex patterns) are essentially a tiny, highly specialized programming language embedded inside Python and made available through the :mod:`re` module. Using this little language, you specify the rules for the set of possible strings that you want to match; this set might contain English sentences, or e-mail addresses, or TeX commands, or anything you like. You can then ask questions such as \"Does this string match the pattern?\", or \"Is there a match for the pattern anywhere in this string?\". You can also use REs to modify a string or to split it apart in various ways."
msgstr "عبارتهای باقاعده (که به آنها RE، regex یا الگوهای regex گفته میشود) در واقع یک زبان برنامهنویسی کوچک و بسیار تخصصی است که درون پایتون تعبیه شده و از طریق ماژول :mod:`re` در دسترس قرار میگیرد. با استفاده از این زبان کوچک، قواعد مجموعهای از رشتههای ممکن را که میخواهید با آنها تطابق انجام دهید مشخص میکنید؛ این مجموعه ممکن است شامل جملات انگلیسی، نشانیهای ایمیل، دستورات TeX یا هر چیزی باشد که بخواهید. سپس میتوانید پرسشهایی مانند «آیا این رشته با الگو تطابق دارد؟» یا «آیا تطابقی برای الگو در هر جای این رشته وجود دارد؟» بپرسید. همچنین میتوانید از REها برای تغییر یک رشته یا تقسیم آن به روشهای مختلف استفاده کنید."
msgid "Regular expression patterns are compiled into a series of bytecodes which are then executed by a matching engine written in C. For advanced use, it may be necessary to pay careful attention to how the engine will execute a given RE, and write the RE in a certain way in order to produce bytecode that runs faster. Optimization isn't covered in this document, because it requires that you have a good understanding of the matching engine's internals."
msgstr "الگوهای عبارت باقاعده به رشتهای از بایتکدها کامپایل میشوند که سپس توسط یک موتور تطبیق نوشتهشده به زبان C اجرا میشوند. برای استفادهی پیشرفته، ممکن است لازم باشد بهدقت به نحوهی اجرای یک RE مشخص توسط موتور توجه کنید و RE را به شکل خاصی بنویسید تا بایتکدی تولید شود که سریعتر اجرا میشود. بهینهسازی در این سند پوشش داده نمیشود، زیرا نیاز دارد که شما درک خوبی از جزئیات داخلی موتور تطبیق داشته باشید."
msgid "The regular expression language is relatively small and restricted, so not all possible string processing tasks can be done using regular expressions. There are also tasks that *can* be done with regular expressions, but the expressions turn out to be very complicated. In these cases, you may be better off writing Python code to do the processing; while Python code will be slower than an elaborate regular expression, it will also probably be more understandable."
msgstr "زبان عبارتهای باقاعده نسبتاً کوچک و محدود است، بنابراین نمیتوان همهی کارهای ممکن در پردازش رشته را با عبارتهای باقاعده انجام داد. همچنین کارهایی وجود دارند که *میتوان* آنها را با عبارتهای باقاعده انجام داد، اما عبارتها بسیار پیچیده میشوند. در این موارد، ممکن است بهتر باشد برای انجام پردازش کد پایتون بنویسید؛ اگرچه کد پایتون از یک عبارت منظم مفصل کندتر خواهد بود، اما احتمالاً قابلفهمتر نیز خواهد بود."
msgid "Simple patterns"
msgstr "الگوهای ساده"
msgid "We'll start by learning about the simplest possible regular expressions. Since regular expressions are used to operate on strings, we'll begin with the most common task: matching characters."
msgstr "با یادگیری سادهترین عبارات باقاعدهی ممکن آغاز میکنیم. از آنجا که عبارات باقاعده برای انجام عملیات روی رشتهها به کار میروند، با رایجترین وظیفه شروع میکنیم: تطبیق نویسهها."
msgid "For a detailed explanation of the computer science underlying regular expressions (deterministic and non-deterministic finite automata), you can refer to almost any textbook on writing compilers."
msgstr "برای توضیحی دقیق درباره علوم کامپیوتری که زیربنای عبارتهای باقاعده است (اتوماتای متناهی قطعی و غیرقطعی)، میتوانید به تقریباً هر کتاب درسی درباره نوشتن کامپایلرها مراجعه کنید."
msgid "Matching characters"
msgstr "تطبیق نویسهها"
msgid "Most letters and characters will simply match themselves. For example, the regular expression ``test`` will match the string ``test`` exactly. (You can enable a case-insensitive mode that would let this RE match ``Test`` or ``TEST`` as well; more about this later.)"
msgstr "بیشتر حروف و نویسهها بهسادگی با خودشان مطابقت دارند. برای مثال، عبارت باقاعدهی ``test`` دقیقاً با رشتهی ``test`` مطابقت خواهد داشت. (میتوانید حالت بدون حساسیت به بزرگی و کوچکی حروف را فعال کنید تا این عبارت باقاعده بتواند با ``Test`` یا ``TEST`` نیز مطابقت داشته باشد؛ بعداً بیشتر دربارهی این موضوع توضیح داده میشود.)"
msgid "There are exceptions to this rule; some characters are special :dfn:`metacharacters`, and don't match themselves. Instead, they signal that some out-of-the-ordinary thing should be matched, or they affect other portions of the RE by repeating them or changing their meaning. Much of this document is devoted to discussing various metacharacters and what they do."
msgstr "برای این قاعده استثناهایی وجود دارد؛ برخی از نویسهها، :dfn:`metacharacters` ویژهای هستند و با خودشان تطابق ندارند. در عوض، آنها نشان میدهند که باید چیز غیرمعمولی تطابق داده شود، یا با تکرار آنها یا تغییر معنایشان، بر بخشهای دیگری از عبارت باقاعده تأثیر میگذارند. بخش عمدهای از این سند به بحث دربارهی فرانویسههای گوناگون و کاری که انجام میدهند اختصاص دارد."
msgid "Here's a complete list of the metacharacters; their meanings will be discussed in the rest of this HOWTO."
msgstr "در اینجا فهرست کاملی از فرانویسهها آمده است؛ معانی آنها در ادامهی این HOWTO بحث خواهد شد."
msgid ". ^ $ * + ? { } [ ] \\ | ( )"
msgstr ". ^ $ * + ? { } [ ] \\ | ( )"
msgid "The first metacharacters we'll look at are ``[`` and ``]``. They're used for specifying a character class, which is a set of characters that you wish to match. Characters can be listed individually, or a range of characters can be indicated by giving two characters and separating them by a ``'-'``. For example, ``[abc]`` will match any of the characters ``a``, ``b``, or ``c``; this is the same as ``[a-c]``, which uses a range to express the same set of characters. If you wanted to match only lowercase letters, your RE would be ``[a-z]``."
msgstr "اولین فرانویسههایی که بررسی خواهیم کرد، ``[`` و ``]`` هستند. آنها برای تعیین یک کلاس نویسه به کار میروند که مجموعهای از نویسههایی است که میخواهید آنها را تطبیق دهید. نویسهها میتوانند بهصورت جداگانه فهرست شوند، یا میتوان یک بازه از نویسهها را با دادن دو نویسه و جدا کردن آنها با یک ``'-'`` مشخص کرد. برای مثال، ``[abc]`` با هر یک از نویسههای ``a``، ``b`` یا ``c`` تطابق دارد؛ این معادل ``[a-c]`` است که از یک بازه برای بیان همان مجموعه از نویسهها استفاده میکند. اگر بخواهید فقط حروف کوچک را تطبیق دهید، RE شما ``[a-z]`` خواهد بود."
msgid "Metacharacters (except ``\\``) are not active inside classes. For example, ``[akm$]`` will match any of the characters ``'a'``, ``'k'``, ``'m'``, or ``'$'``; ``'$'`` is usually a metacharacter, but inside a character class it's stripped of its special nature."
msgstr "فرانویسهها (به جز ``\\``) درون کلاسها فعال نیستند. برای مثال، ``[akm$]`` با هر یک از نویسههای ``'a'``، ``'k'``، ``'m'`` یا ``'$'`` مطابقت دارد؛ ``'$'`` معمولاً یک فرانویسه است، اما درون یک کلاس نویسه، خاصیت ویژهی آن حذف میشود."
msgid "You can match the characters not listed within the class by :dfn:`complementing` the set. This is indicated by including a ``'^'`` as the first character of the class. For example, ``[^5]`` will match any character except ``'5'``. If the caret appears elsewhere in a character class, it does not have special meaning. For example: ``[5^]`` will match either a ``'5'`` or a ``'^'``."
msgstr "میتوانید با :dfn:`متممسازی <complementing>` مجموعه، نویسههایی را که در کلاس فهرست نشدهاند تطبیق دهید. این کار با قرار دادن ``'^'`` بهعنوان اولین نویسهی کلاس مشخص میشود. برای مثال، ``[^5]`` هر نویسهای به جز ``'5'`` را تطبیق میدهد. اگر نویسهی ^ در جای دیگری از یک کلاس نویسه ظاهر شود، معنای خاصی ندارد. برای مثال: ``[5^]`` یا ``'5'`` یا ``'^'`` را تطبیق میدهد."
msgid "Perhaps the most important metacharacter is the backslash, ``\\``. As in Python string literals, the backslash can be followed by various characters to signal various special sequences. It's also used to escape all the metacharacters so you can still match them in patterns; for example, if you need to match a ``[`` or ``\\``, you can precede them with a backslash to remove their special meaning: ``\\[`` or ``\\\\``."
msgstr "شاید مهمترین فرانویسه، بکاسلش، ``\\`` باشد. مانند مقادیر لفظی رشته پایتون، پس از بکاسلش میتوان از نویسههای مختلفی استفاده کرد تا دنبالههای ویژهی گوناگون نشان داده شوند. همچنین از آن برای خنثی کردن همهی فرانویسهها استفاده میشود تا همچنان بتوانید آنها را در الگوها تطبیق دهید؛ برای مثال، اگر نیاز دارید ``[`` یا ``\\`` را تطبیق دهید، میتوانید پیش از آنها یک بکاسلش قرار دهید تا معنای خاص آنها از بین برود: ``\\[`` یا ``\\\\``."
msgid "Some of the special sequences beginning with ``'\\'`` represent predefined sets of characters that are often useful, such as the set of digits, the set of letters, or the set of anything that isn't whitespace."
msgstr "برخی از دنبالههای خاص که با ``'\\'`` آغاز میشوند، بیانگر مجموعههای از پیش تعریفشدهای از نویسهها هستند که اغلب مفید هستند، مانند مجموعه ارقام، مجموعه حروف، یا مجموعه هر چیزی غیر از فضای سفید."
msgid "Let's take an example: ``\\w`` matches any alphanumeric character. If the regex pattern is expressed in bytes, this is equivalent to the class ``[a-zA-Z0-9_]``. If the regex pattern is a string, ``\\w`` will match all the characters marked as letters in the Unicode database provided by the :mod:`unicodedata` module. You can use the more restricted definition of ``\\w`` in a string pattern by supplying the :const:`re.ASCII` flag when compiling the regular expression."
msgstr "مثالی را در نظر بگیرید: ``\\w`` با هر نویسهی الفباییعددی مطابقت دارد. اگر الگوی عبارت باقاعده بهصورت بایت بیان شده باشد، این معادل کلاس ``[a-zA-Z0-9_]`` است. اگر الگوی عبارت باقاعده یک رشته باشد، ``\\w`` با تمام نویسههایی که در پایگاه دادهی یونیکد ارائهشده توسط ماژول :mod:`unicodedata` بهعنوان حرف علامتگذاری شدهاند، مطابقت خواهد کرد. شما میتوانید با استفاده از پرچم :const:`re.ASCII` هنگام کامپایل عبارت باقاعده، از تعریف محدودتر ``\\w`` در یک الگوی رشتهای استفاده کنید."
msgid "The following list of special sequences isn't complete. For a complete list of sequences and expanded class definitions for Unicode string patterns, see the last part of :ref:`Regular Expression Syntax <re-syntax>` in the Standard Library reference. In general, the Unicode versions match any character that's in the appropriate category in the Unicode database."
msgstr "فهرست زیر از دنبالههای ویژه کامل نیست. برای فهرست کاملی از دنبالهها و تعریفهای گسترشیافته کلاس برای الگوهای رشته یونیکد، بخش پایانی :ref:`سینتکس عبارت باقاعده <re-syntax>` را در مرجع کتابخانه استاندارد ببینید. بهطور کلی، نسخههای یونیکد با هر نویسهای که در دسته مناسب در پایگاه داده یونیکد قرار دارد، مطابقت میکنند."
msgid "``\\d``"
msgstr "``\\d``"
msgid "Matches any decimal digit; this is equivalent to the class ``[0-9]``."
msgstr "با هر رقم دهدهی مطابقت دارد؛ این معادل کلاس ``[0-9]`` است."
msgid "``\\D``"
msgstr "``\\D``"
msgid "Matches any non-digit character; this is equivalent to the class ``[^0-9]``."
msgstr "با هر نویسهی غیررقمی مطابقت دارد؛ این معادل کلاس ``[^0-9]`` است."
msgid "``\\s``"
msgstr "``\\s``"
msgid "Matches any whitespace character; this is equivalent to the class ``[ \\t\\n\\r\\f\\v]``."
msgstr "با هر نویسه فضای سفید مطابقت دارد؛ این معادل کلاس ``[ \\t\\n\\r\\f\\v]`` است."
msgid "``\\S``"
msgstr "``\\S``"
msgid "Matches any non-whitespace character; this is equivalent to the class ``[^ \\t\\n\\r\\f\\v]``."
msgstr "با هر نویسهای که فضای خالی نیست مطابقت دارد؛ این معادل کلاس ``[^ \\t\\n\\r\\f\\v]`` است."
msgid "``\\w``"
msgstr "``\\w``"
msgid "Matches any alphanumeric character; this is equivalent to the class ``[a-zA-Z0-9_]``."
msgstr "با هر نویسهی الفبایی-عددی مطابقت دارد؛ این معادل کلاس ``[a-zA-Z0-9_]`` است."
msgid "``\\W``"
msgstr "``\\W``"
msgid "Matches any non-alphanumeric character; this is equivalent to the class ``[^a-zA-Z0-9_]``."
msgstr "با هر نویسهی غیرالفبایی-عددی مطابقت دارد؛ این معادل کلاس ``[^a-zA-Z0-9_]`` است."
msgid "These sequences can be included inside a character class. For example, ``[\\s,.]`` is a character class that will match any whitespace character, or ``','`` or ``'.'``."
msgstr "این دنبالهها میتوانند درون یک کلاس نویسه گنجانده شوند. برای مثال، ``[\\s,.]`` یک کلاس نویسه است که با هر نویسه فضای سفید، یا ``','`` یا ``'.'`` مطابقت خواهد داشت."
msgid "The final metacharacter in this section is ``.``. It matches anything except a newline character, and there's an alternate mode (:const:`re.DOTALL`) where it will match even a newline. ``.`` is often used where you want to match \"any character\"."
msgstr "آخرین فرانویس سرآیند این بخش ``.`` است. این با هر چیزی بهجز نویسهی خط جدید تطابق دارد و حالت جایگزینی (:const:`re.DOTALL`) وجود دارد که در آن حتی با خط جدید نیز تطابق خواهد داشت. از ``.`` اغلب در جایی استفاده میشود که بخواهید با «هر نویسهای» تطابق داشته باشید."
msgid "Repeating things"
msgstr "تکرار چیزها"
msgid "Being able to match varying sets of characters is the first thing regular expressions can do that isn't already possible with the methods available on strings. However, if that was the only additional capability of regexes, they wouldn't be much of an advance. Another capability is that you can specify that portions of the RE must be repeated a certain number of times."
msgstr "توانایی تطبیق مجموعههای متفاوتی از نویسهها نخستین کاری است که عبارتهای باقاعده میتوانند انجام دهند و با متدهای موجود برای رشتهها از پیش امکانپذیر نیست. با این حال، اگر این تنها قابلیت اضافی عبارتهای باقاعده بود، پیشرفت چندانی محسوب نمیشدند. قابلیت دیگر این است که میتوانید مشخص کنید بخشهایی از عبارت باقاعده باید تعداد معینی تکرار شوند."
msgid "The first metacharacter for repeating things that we'll look at is ``*``. ``*`` doesn't match the literal character ``'*'``; instead, it specifies that the previous character can be matched zero or more times, instead of exactly once."
msgstr "اولین فرانویسه برای تکرار که بررسی خواهیم کرد، ``*`` است. ``*`` با نویسهی عینی ``'*'`` تطابق ندارد؛ در عوض، مشخص میکند که نویسهی قبلی میتواند به جای دقیقاً یک بار، صفر بار یا بیشتر تطابق داشته باشد."
msgid "For example, ``ca*t`` will match ``'ct'`` (0 ``'a'`` characters), ``'cat'`` (1 ``'a'``), ``'caaat'`` (3 ``'a'`` characters), and so forth."
msgstr "برای مثال، ``ca*t`` با ``'ct'`` (۰ نویسه ``'a'``)، ``'cat'`` (۱ ``'a'``)، ``'caaat'`` (۳ نویسه ``'a'``) و غیره مطابقت دارد."
msgid "Repetitions such as ``*`` are :dfn:`greedy`; when repeating a RE, the matching engine will try to repeat it as many times as possible. If later portions of the pattern don't match, the matching engine will then back up and try again with fewer repetitions."
msgstr "تکرارهایی مانند ``*`` :dfn:`حریص <greedy>` هستند؛ هنگام تکرار یک RE، موتور تطبیق تلاش میکند آن را تا حد ممکن تکرار کند. اگر بخشهای بعدی الگو مطابقت نداشته باشند، موتور تطبیق سپس عقبگرد میکند و دوباره با تکرارهای کمتر تلاش میکند."
msgid "A step-by-step example will make this more obvious. Let's consider the expression ``a[bcd]*b``. This matches the letter ``'a'``, zero or more letters from the class ``[bcd]``, and finally ends with a ``'b'``. Now imagine matching this RE against the string ``'abcbd'``."
msgstr "یک مثال گامبهگام این موضوع را روشنتر میکند. عبارت ``a[bcd]*b`` را در نظر بگیرید. این عبارت با نویسه ``'a'``، صفر یا چند نویسه از کلاس ``[bcd]`` مطابقت میکند و در نهایت با یک ``'b'`` تمام میشود. حال مطابقت این عبارت باقاعده (RE) با رشته ``'abcbd'`` را تصور کنید."
msgid "Step"
msgstr "مرحله"
msgid "Matched"
msgstr "تطبیقشده"
msgid "Explanation"
msgstr "توضیح"
msgid "1"
msgstr "1"
msgid "``a``"
msgstr "``a``"
msgid "The ``a`` in the RE matches."
msgstr "``a`` در RE مطابقت میکند."
msgid "2"
msgstr "2"
msgid "``abcbd``"
msgstr "``abcbd``"
msgid "The engine matches ``[bcd]*``, going as far as it can, which is to the end of the string."
msgstr "موتور، ``[bcd]*`` را تطابق میدهد و تا جایی که میتواند پیش میرود، یعنی تا انتهای رشته."
msgid "3"
msgstr "3"
msgid "*Failure*"
msgstr "*Failure*"
msgid "The engine tries to match ``b``, but the current position is at the end of the string, so it fails."
msgstr "موتور تلاش میکند ``b`` را تطبیق دهد، اما موقعیت فعلی در انتهای رشته قرار دارد، بنابراین شکست میخورد."
msgid "4"
msgstr "4"
msgid "``abcb``"
msgstr "``abcb``"
msgid "Back up, so that ``[bcd]*`` matches one less character."
msgstr "به عقب برگردید، تا ``[bcd]*`` با یک نویسه کمتر مطابقت داشته باشد."
msgid "5"
msgstr "۵"
msgid "Try ``b`` again, but the current position is at the last character, which is a ``'d'``."
msgstr "بار دیگر ``b`` را امتحان کنید، اما موقعیت فعلی روی آخرین نویسه قرار دارد که یک ``'d'`` است."
msgid "6"
msgstr "6"
msgid "``abc``"
msgstr "``abc``"
msgid "Back up again, so that ``[bcd]*`` is only matching ``bc``."
msgstr "دوباره عقبگرد کنید، بهطوریکه ``[bcd]*`` فقط ``bc`` را تطبیق دهد."
msgid "7"
msgstr "۷"
msgid "Try ``b`` again. This time the character at the current position is ``'b'``, so it succeeds."
msgstr "دوباره ``b`` را امتحان کنید. این بار نویسهی موقعیت فعلی ``'b'`` است، بنابراین موفق میشود."
msgid "The end of the RE has now been reached, and it has matched ``'abcb'``. This demonstrates how the matching engine goes as far as it can at first, and if no match is found it will then progressively back up and retry the rest of the RE again and again. It will back up until it has tried zero matches for ``[bcd]*``, and if that subsequently fails, the engine will conclude that the string doesn't match the RE at all."
msgstr "اکنون به انتهای RE رسیدهایم و آن با ``'abcb'`` مطابقت کرده است. این نشان میدهد که موتور تطبیق در ابتدا تا جایی که میتواند پیش میرود و اگر هیچ تطابقی پیدا نشود، سپس بهتدریج عقب میرود و بقیهی RE را بارها و بارها دوباره امتحان میکند. آنقدر عقب میرود تا صفر تطابق را برای ``[bcd]*`` امتحان کند و اگر سپس شکست بخورد، موتور نتیجه میگیرد که رشته اصلاً با RE مطابقت ندارد."
msgid "Another repeating metacharacter is ``+``, which matches one or more times. Pay careful attention to the difference between ``*`` and ``+``; ``*`` matches *zero* or more times, so whatever's being repeated may not be present at all, while ``+`` requires at least *one* occurrence. To use a similar example, ``ca+t`` will match ``'cat'`` (1 ``'a'``), ``'caaat'`` (3 ``'a'``\\ s), but won't match ``'ct'``."
msgstr "یکی دیگر از فرانویسههای تکرار، ``+`` است که یک یا چند بار تطابق دارد. به تفاوت میان ``*`` و ``+`` با دقت توجه کنید؛ ``*`` *صفر* یا چند بار تطابق دارد، بنابراین ممکن است هر آنچه تکرار میشود اصلاً وجود نداشته باشد، در حالی که ``+`` حداقل به *یک* بار نیاز دارد. برای استفاده از مثالی مشابه، ``ca+t`` با ``'cat'`` (۱ ``'a'``)، ``'caaat'`` (۳ ``'a'``) تطابق خواهد داشت، اما با ``'ct'`` تطابق نخواهد داشت."
msgid "There are two more repeating operators or quantifiers. The question mark character, ``?``, matches either once or zero times; you can think of it as marking something as being optional. For example, ``home-?brew`` matches either ``'homebrew'`` or ``'home-brew'``."
msgstr "دو عملگر تکرار یا کمیتگذار دیگر نیز وجود دارد. نویسهی علامت سؤال، ``?``، یا یک بار یا صفر بار تطابق مییابد؛ میتوانید آن را بهعنوان علامتگذاری اختیاری بودن چیزی در نظر بگیرید. برای مثال، ``home-?brew`` یا با ``'homebrew'`` یا با ``'home-brew'`` تطابق دارد."
msgid "The most complicated quantifier is ``{m,n}``, where *m* and *n* are decimal integers. This quantifier means there must be at least *m* repetitions, and at most *n*. For example, ``a/{1,3}b`` will match ``'a/b'``, ``'a//b'``, and ``'a///b'``. It won't match ``'ab'``, which has no slashes, or ``'a////b'``, which has four."
msgstr "پیچیدهترین کمیتگذار (quantifier) ``{m,n}`` است که در آن *m* و *n* اعداد صحیح مبنای ده هستند. این کمیتگذار به این معناست که باید حداقل *m* تکرار و حداکثر *n* تکرار وجود داشته باشد. برای مثال، ``a/{1,3}b`` با ``'a/b'``، ``'a//b'`` و ``'a///b'`` مطابقت خواهد کرد. این الگو با ``'ab'`` که هیچ اسلشی ندارد، یا ``'a////b'`` که چهار اسلش دارد، مطابقت نخواهد کرد."
msgid "You can omit either *m* or *n*; in that case, a reasonable value is assumed for the missing value. Omitting *m* is interpreted as a lower limit of 0, while omitting *n* results in an upper bound of infinity."
msgstr "میتوانید *m* یا *n* را حذف کنید؛ در این صورت، یک مقدار معقول برای مقدار غایب فرض میشود. حذف *m* بهعنوان کران پایین ۰ تفسیر میشود، در حالی که حذف *n* به کران بالای بینهایت منجر میشود."
msgid "The simplest case ``{m}`` matches the preceding item exactly *m* times. For example, ``a/{2}b`` will only match ``'a//b'``."
msgstr "سادهترین حالت ``{m}`` دقیقاً *m* بار با آیتم پیشین مطابقت دارد. برای مثال، ``a/{2}b`` فقط با ``'a//b'`` مطابقت خواهد داشت."
msgid "Readers of a reductionist bent may notice that the three other quantifiers can all be expressed using this notation. ``{0,}`` is the same as ``*``, ``{1,}`` is equivalent to ``+``, and ``{0,1}`` is the same as ``?``. It's better to use ``*``, ``+``, or ``?`` when you can, simply because they're shorter and easier to read."
msgstr "خوانندگان با گرایش تقلیلگرایانه ممکن است متوجه شوند که سه کمیتگذار دیگر را میتوان با استفاده از این نمادگذاری بیان کرد. ``{0,}`` همان ``*`` است، ``{1,}`` معادل ``+`` است، و ``{0,1}`` همان ``?`` است. بهتر است در صورت امکان از ``*``، ``+`` یا ``?`` استفاده کنید، صرفاً به این دلیل که کوتاهتر و خواناتر هستند."
msgid "Using regular expressions"
msgstr "استفاده از عبارات باقاعده"
msgid "Now that we've looked at some simple regular expressions, how do we actually use them in Python? The :mod:`re` module provides an interface to the regular expression engine, allowing you to compile REs into objects and then perform matches with them."
msgstr "اکنون که برخی عبارتهای باقاعده ساده را بررسی کردیم، چگونه واقعاً از آنها در پایتون استفاده کنیم؟ ماژول :mod:`re` رابطی به موتور عبارتهای باقاعده فراهم میکند و به شما امکان میدهد REها را به اشیاء کامپایل کنید و سپس با آنها تطبیقها را انجام دهید."
msgid "Compiling regular expressions"
msgstr "کامپایل عبارتهای باقاعده"
msgid "Regular expressions are compiled into pattern objects, which have methods for various operations such as searching for pattern matches or performing string substitutions. ::"
msgstr "عبارتهای باقاعده به اشیای الگو کامپایل میشوند، که متدهایی برای عملیات مختلف مانند جستوجو برای تطابقهای الگو یا انجام جایگزینیهای رشتهای دارند. ::"
msgid ""
">>> import re\n"
">>> p = re.compile('ab*')\n"
">>> p\n"
"re.compile('ab*')"
msgstr ""
">>> import re\n"
">>> p = re.compile('ab*')\n"
">>> p\n"
"re.compile('ab*')"
msgid ":func:`re.compile` also accepts an optional *flags* argument, used to enable various special features and syntax variations. We'll go over the available settings later, but for now a single example will do::"
msgstr ":func:`re.compile` همچنین یک آرگومان اختیاری *flags* را میپذیرد که برای فعالسازی قابلیتهای ویژه و تغییرات سینتکسی گوناگون استفاده میشود. بعداً تنظیمات موجود را بررسی خواهیم کرد، اما فعلاً یک مثال کافی است::"
msgid ">>> p = re.compile('ab*', re.IGNORECASE)"
msgstr ">>> p = re.compile('ab*', re.IGNORECASE)"
msgid "The RE is passed to :func:`re.compile` as a string. REs are handled as strings because regular expressions aren't part of the core Python language, and no special syntax was created for expressing them. (There are applications that don't need REs at all, so there's no need to bloat the language specification by including them.) Instead, the :mod:`re` module is simply a C extension module included with Python, just like the :mod:`socket` or :mod:`zlib` modules."
msgstr "RE بهصورت یک رشته به :func:`re.compile` ارسال میشود. REها بهصورت رشته پردازش میشوند، زیرا عبارتهای باقاعده بخشی از زبان اصلی پایتون نیستند و هیچ سینتکس خاصی برای بیان آنها ایجاد نشده است. (برنامههایی وجود دارند که اصلاً به RE نیاز ندارند، بنابراین نیازی به حجیم کردن مشخصات زبان با گنجاندن آنها نیست.) در عوض، ماژول :mod:`re` صرفاً یک ماژول توسعه C است که همراه با پایتون گنجانده شده است، درست مانند ماژولهای :mod:`socket` یا :mod:`zlib`."
msgid "Putting REs in strings keeps the Python language simpler, but has one disadvantage which is the topic of the next section."
msgstr "قرار دادن عبارتهای باقاعده در رشتهها، زبان پایتون را سادهتر نگه میدارد، اما یک عیب دارد که موضوع بخش بعدی است."
msgid "The backslash plague"
msgstr "آفت بکاسلش"
msgid "As stated earlier, regular expressions use the backslash character (``'\\'``) to indicate special forms or to allow special characters to be used without invoking their special meaning. This conflicts with Python's usage of the same character for the same purpose in string literals."
msgstr "همانطور که پیشتر گفته شد، عبارات باقاعده از نویسهی بکاسلش (``'\\'``) استفاده میکنند تا شکلهای ویژه را نشان دهند یا اجازه دهند که نویسههای ویژه بدون فراخوانی معنای ویژهی آنها به کار گرفته شوند. این موضوع با استفادهی پایتون از همان نویسه برای همان هدف در رشتههای لفظی (string literals) تعارض دارد."
msgid "Let's say you want to write a RE that matches the string ``\\section``, which might be found in a LaTeX file. To figure out what to write in the program code, start with the desired string to be matched. Next, you must escape any backslashes and other metacharacters by preceding them with a backslash, resulting in the string ``\\\\section``. The resulting string that must be passed to :func:`re.compile` must be ``\\\\section``. However, to express this as a Python string literal, both backslashes must be escaped *again*."
msgstr "فرض کنید میخواهید یک عبارت باقاعده بنویسید که با رشتهی ``\\section`` مطابقت کند، که ممکن است در یک پرونده LaTeX یافت شود. برای اینکه بدانید در کد برنامه چه بنویسید، با رشتهی موردنظر برای مطابقت شروع کنید. سپس باید هر بکاسلش و سایر متانویسهها را با قرار دادن یک بکاسلش پیش از آنها خنثی کنید، که در نتیجه رشتهی ``\\\\section`` به دست میآید. رشتهی حاصل که باید به :func:`re.compile` داده شود، باید ``\\\\section`` باشد. با این حال، برای بیان این بهعنوان یک رشتهی لفظی پایتون، هر دو بکاسلش باید *دوباره* خنثی شوند."
msgid "Characters"
msgstr "نویسهها"
msgid "Stage"
msgstr "مرحله"
msgid "``\\section``"
msgstr "``\\section``"
msgid "Text string to be matched"
msgstr "رشتهی متنی برای تطبیق"
msgid "``\\\\section``"
msgstr "``\\\\section``"
msgid "Escaped backslash for :func:`re.compile`"
msgstr "بکاسلش خنثیشده برای :func:`re.compile`"
msgid "``\"\\\\\\\\section\"``"
msgstr "``\"\\\\\\\\section\"``"
msgid "Escaped backslashes for a string literal"
msgstr "بکاسلشهای خنثیشده برای یک رشتهی لفظی"
msgid "In short, to match a literal backslash, one has to write ``'\\\\\\\\'`` as the RE string, because the regular expression must be ``\\\\``, and each backslash must be expressed as ``\\\\`` inside a regular Python string literal. In REs that feature backslashes repeatedly, this leads to lots of repeated backslashes and makes the resulting strings difficult to understand."
msgstr "بهطور خلاصه، برای تطبیق یک بکاسلش بهصورت لفظی، باید ``'\\\\\\\\'`` را بهعنوان رشتهی عبارت باقاعده بنویسید، زیرا عبارت باقاعده باید ``\\\\`` باشد و هر بکاسلش باید داخل یک رشتهی معمولی پایتون بهصورت ``\\\\`` بیان شود. در عبارتهای باقاعدهای که شامل بکاسلشهای مکرر هستند، این موضوع به تکرار زیاد بکاسلشها منجر میشود و درک رشتههای حاصل را دشوار میسازد."
msgid "The solution is to use Python's raw string notation for regular expressions; backslashes are not handled in any special way in a string literal prefixed with ``'r'``, so ``r\"\\n\"`` is a two-character string containing ``'\\'`` and ``'n'``, while ``\"\\n\"`` is a one-character string containing a newline. Regular expressions will often be written in Python code using this raw string notation."
msgstr "راهحل این است که از نمادگذاری رشتهی خام پایتون برای عبارات باقاعده استفاده کنید؛ بکاسلشها در یک رشتهی ادبی با پیشوند ``'r'`` به هیچ شکل خاصی پردازش نمیشوند، بنابراین ``r\"\\n\"`` یک رشتهی دو نویسهای است که شامل ``'\\'`` و ``'n'`` است، در حالی که ``\"\\n\"`` یک رشتهی تکنویسهای است که شامل یک خط جدید است. عبارات باقاعده اغلب با استفاده از این نمادگذاری رشتهی خام در کد پایتون نوشته میشوند."
msgid "In addition, special escape sequences that are valid in regular expressions, but not valid as Python string literals, now result in a :exc:`SyntaxWarning` and will eventually become a :exc:`SyntaxError`, which means the sequences will be invalid if raw string notation or escaping the backslashes isn't used."
msgstr "بهعلاوه، دنبالههای خنثیسازی خاصی که در عبارات باقاعده معتبرند، اما بهعنوان مقادیر لفظی رشته پایتون معتبر نیستند، اکنون منجر به :exc:`SyntaxWarning` میشوند و سرانجام به :exc:`SyntaxError` تبدیل خواهند شد؛ این بدان معناست که اگر از نمادگذاری رشته خام یا خنثی کردن بکاسلشها استفاده نشود، این دنبالهها نامعتبر خواهند بود."
msgid "Regular String"
msgstr "رشته معمولی"
msgid "Raw string"
msgstr "رشته خام"
msgid "``\"ab*\"``"
msgstr "``\"ab*\"``"
msgid "``r\"ab*\"``"
msgstr "``r\"ab*\"``"
msgid "``r\"\\\\section\"``"
msgstr "``r\"\\\\section\"``"
msgid "``\"\\\\w+\\\\s+\\\\1\"``"
msgstr "``\"\\\\w+\\\\s+\\\\1\"``"
msgid "``r\"\\w+\\s+\\1\"``"
msgstr "``r\"\\w+\\s+\\1\"``"
msgid "Performing matches"
msgstr "انجام تطبیقها"
msgid "Once you have an object representing a compiled regular expression, what do you do with it? Pattern objects have several methods and attributes. Only the most significant ones will be covered here; consult the :mod:`re` docs for a complete listing."
msgstr "هنگامی که یک شیء نشاندهنده یک عبارت باقاعده کامپایلشده دارید، با آن چه کار میکنید؟ اشیای الگو چندین متد و ویژگی دارند. در اینجا فقط مهمترین آنها بررسی میشود؛ برای فهرست کامل به مستندات :mod:`re` مراجعه کنید."
msgid "Method/Attribute"
msgstr "متد/ویژگی"
msgid "Purpose"
msgstr "هدف"
msgid "``match()``"
msgstr "``match()``"
msgid "Determine if the RE matches at the beginning of the string."
msgstr "تعیین میکند که آیا عبارت باقاعده در ابتدای رشته تطابق دارد یا خیر."
msgid "``search()``"
msgstr "``search()``"
msgid "Scan through a string, looking for any location where this RE matches."
msgstr "یک رشته را پیمایش میکند و به دنبال هر موقعیتی میگردد که این عبارت باقاعده در آن مطابقت دارد."
msgid "``findall()``"
msgstr "``findall()``"
msgid "Find all substrings where the RE matches, and return them as a list."
msgstr "همه زیررشتههایی را که RE با آنها مطابقت دارد پیدا میکند و آنها را بهصورت یک فهرست برمیگرداند."
msgid "``finditer()``"
msgstr "``finditer()``"
msgid "Find all substrings where the RE matches, and return them as an :term:`iterator`."
msgstr "تمام زیررشتههایی را که RE با آنها مطابقت دارد پیدا کنید و آنها را بهعنوان یک :term:`iterator` برگردانید."
msgid ":meth:`~re.Pattern.match` and :meth:`~re.Pattern.search` return ``None`` if no match can be found. If they're successful, a :ref:`match object <match-objects>` instance is returned, containing information about the match: where it starts and ends, the substring it matched, and more."
msgstr ":meth:`~re.Pattern.match` و :meth:`~re.Pattern.search` در صورتی که هیچ تطابقی یافت نشود، ``None`` برمیگردانند. اگر موفق باشند، نمونهای از :ref:`شیء تطابق <match-objects>` برگردانده میشود که حاوی اطلاعاتی دربارهی تطابق است: محل شروع و پایان آن، زیررشتهای که با آن تطابق داشته است، و موارد دیگر."
msgid "You can learn about this by interactively experimenting with the :mod:`re` module."
msgstr "میتوانید با آزمایش تعاملی ماژول :mod:`re`، درباره این موضوع بیاموزید."
msgid "This HOWTO uses the standard Python interpreter for its examples. First, run the Python interpreter, import the :mod:`re` module, and compile a RE::"
msgstr "این HOWTO برای مثالهای خود از مفسر استاندارد پایتون استفاده میکند. ابتدا مفسر پایتون را اجرا کنید، ماژول :mod:`re` را ایمپورت کنید و یک RE را کامپایل کنید::"
msgid ""
">>> import re\n"
">>> p = re.compile('[a-z]+')\n"
">>> p\n"
"re.compile('[a-z]+')"
msgstr ""
">>> import re\n"
">>> p = re.compile('[a-z]+')\n"
">>> p\n"
"re.compile('[a-z]+')"
msgid "Now, you can try matching various strings against the RE ``[a-z]+``. An empty string shouldn't match at all, since ``+`` means 'one or more repetitions'. :meth:`~re.Pattern.match` should return ``None`` in this case, which will cause the interpreter to print no output. You can explicitly print the result of :meth:`!match` to make this clear. ::"
msgstr "اکنون میتوانید تطبیق رشتههای مختلف با عبارت باقاعده ``[a-z]+`` را امتحان کنید. یک رشته خالی بههیچوجه نباید تطبیق پیدا کند، زیرا ``+`` به معنای «یک یا چند تکرار» است. در این حالت :meth:`~re.Pattern.match` باید ``None`` برگرداند، که باعث میشود مفسر هیچ خروجی چاپ نکند. میتوانید برای روشنتر شدن این موضوع، نتیجه :meth:`!match` را بهصورت صریح چاپ کنید. ::"
msgid ""
">>> p.match(\"\")\n"
">>> print(p.match(\"\"))\n"
"None"
msgstr ""
">>> p.match(\"\")\n"
">>> print(p.match(\"\"))\n"
"None"
msgid "Now, let's try it on a string that it should match, such as ``tempo``. In this case, :meth:`~re.Pattern.match` will return a :ref:`match object <match-objects>`, so you should store the result in a variable for later use. ::"
msgstr "اکنون، بیایید آن را روی رشتهای که باید با آن تطبیق داشته باشد، مانند ``tempo`` امتحان کنیم. در این حالت، :meth:`~re.Pattern.match` یک :ref:`شیء تطبیق <match-objects>` برمیگرداند، بنابراین باید نتیجه را برای استفاده بعدی در یک متغیر ذخیره کنید. ::"
msgid ""
">>> m = p.match('tempo')\n"
">>> m\n"
"<re.Match object; span=(0, 5), match='tempo'>"
msgstr ""
">>> m = p.match('tempo')\n"
">>> m\n"
"<re.Match object; span=(0, 5), match='tempo'>"
msgid "Now you can query the :ref:`match object <match-objects>` for information about the matching string. Match object instances also have several methods and attributes; the most important ones are:"
msgstr "اکنون میتوانید برای دریافت اطلاعات درباره رشتهی تطبیقیافته، از :ref:`شیء تطبیق <match-objects>` پرسوجو کنید. نمونههای شیء تطبیق همچنین چندین متد و ویژگی دارند؛ مهمترین آنها عبارتاند از:"
msgid "``group()``"
msgstr "``group()``"
msgid "Return the string matched by the RE"
msgstr "رشتهی تطبیقیافته با RE را برمیگرداند"
msgid "``start()``"
msgstr "``start()``"
msgid "Return the starting position of the match"
msgstr "موقعیت شروع تطبیق را برمیگرداند"
msgid "``end()``"
msgstr "``end()``"
msgid "Return the ending position of the match"
msgstr "موقعیت پایانی تطابق را برمیگرداند"
msgid "``span()``"
msgstr "``span()``"
msgid "Return a tuple containing the (start, end) positions of the match"
msgstr "یک تاپل شامل موقعیتهای (start, end) تطبیق را برمیگرداند"
msgid "Trying these methods will soon clarify their meaning::"
msgstr "آزمودن این متدها بهزودی معنای آنها را روشن خواهد کرد::"
msgid ""
">>> m.group()\n"
"'tempo'\n"
">>> m.start(), m.end()\n"
"(0, 5)\n"
">>> m.span()\n"
"(0, 5)"
msgstr ""
">>> m.group()\n"
"'tempo'\n"
">>> m.start(), m.end()\n"
"(0, 5)\n"
">>> m.span()\n"
"(0, 5)"
msgid ":meth:`~re.Match.group` returns the substring that was matched by the RE. :meth:`~re.Match.start` and :meth:`~re.Match.end` return the starting and ending index of the match. :meth:`~re.Match.span` returns both start and end indexes in a single tuple. Since the :meth:`~re.Pattern.match` method only checks if the RE matches at the start of a string, :meth:`!start` will always be zero. However, the :meth:`~re.Pattern.search` method of patterns scans through the string, so the match may not start at zero in that case. ::"
msgstr ":meth:`~re.Match.group` زیررشتهای را برمیگرداند که با عبارت باقاعده مطابقت داشته است. :meth:`~re.Match.start` و :meth:`~re.Match.end` اندیسهای شروع و پایان تطابق را برمیگردانند. :meth:`~re.Match.span` هر دو اندیس شروع و پایان را در یک تاپل واحد برمیگرداند. از آنجا که متد :meth:`~re.Pattern.match` فقط بررسی میکند که آیا عبارت باقاعده در ابتدای یک رشته تطابق دارد یا خیر، :meth:`!start` همیشه ۰ خواهد بود. با این حال، متد :meth:`~re.Pattern.search` الگوها، رشته را پیمایش میکند، بنابراین در آن حالت ممکن است تطابق از ۰ شروع نشود. ::"
msgid ""
">>> print(p.match('::: message'))\n"
"None\n"
">>> m = p.search('::: message'); print(m)\n"
"<re.Match object; span=(4, 11), match='message'>\n"
">>> m.group()\n"
"'message'\n"
">>> m.span()\n"
"(4, 11)"
msgstr ""
">>> print(p.match('::: message'))\n"
"None\n"
">>> m = p.search('::: message'); print(m)\n"
"<re.Match object; span=(4, 11), match='message'>\n"
">>> m.group()\n"
"'message'\n"
">>> m.span()\n"
"(4, 11)"
msgid "In actual programs, the most common style is to store the :ref:`match object <match-objects>` in a variable, and then check if it was ``None``. This usually looks like::"
msgstr "در برنامههای واقعی، رایجترین سبک این است که :ref:`شیء تطبیق <match-objects>` را در یک متغیر ذخیره کنید و سپس بررسی کنید که آیا ``None`` است یا خیر. این معمولاً به این شکل است::"
msgid ""
"p = re.compile( ... )\n"
"m = p.match( 'string goes here' )\n"
"if m:\n"
" print('Match found: ', m.group())\n"
"else:\n"
" print('No match')"
msgstr ""
"p = re.compile( ... )\n"
"m = p.match( 'string goes here' )\n"
"if m:\n"
" print('Match found: ', m.group())\n"
"else:\n"
" print('No match')"
msgid "Two pattern methods return all of the matches for a pattern. :meth:`~re.Pattern.findall` returns a list of matching strings::"
msgstr "دو متد الگو، همهی تطابقهای یک الگو را برمیگردانند. :meth:`~re.Pattern.findall` فهرستی از رشتههای مطابقتکننده را برمیگرداند::"
msgid ""
">>> p = re.compile(r'\\d+')\n"
">>> p.findall('12 drummers drumming, 11 pipers piping, 10 lords a-leaping')\n"
"['12', '11', '10']"
msgstr ""
">>> p = re.compile(r'\\d+')\n"
">>> p.findall('12 drummers drumming, 11 pipers piping, 10 lords a-leaping')\n"
"['12', '11', '10']"
msgid "The ``r`` prefix, making the literal a raw string literal, is needed in this example because escape sequences in a normal \"cooked\" string literal that are not recognized by Python, as opposed to regular expressions, now result in a :exc:`SyntaxWarning` and will eventually become a :exc:`SyntaxError`. See :ref:`the-backslash-plague`."
msgstr "پیشوند ``r`` که این رشته را به یک رشتهی خام تبدیل میکند، در این مثال لازم است، زیرا دنبالههای فرار در یک رشتهی معمولی «پخته» (cooked) که توسط پایتون، برخلاف عبارات باقاعده، شناسایی نمیشوند، اکنون منجر به :exc:`SyntaxWarning` میشوند و سرانجام به :exc:`SyntaxError` تبدیل خواهند شد. به :ref:`the-backslash-plague` مراجعه کنید."
msgid ":meth:`~re.Pattern.findall` has to create the entire list before it can be returned as the result. The :meth:`~re.Pattern.finditer` method returns a sequence of :ref:`match object <match-objects>` instances as an :term:`iterator`::"
msgstr ":meth:`~re.Pattern.findall` باید کل فهرست را ایجاد کند تا بتواند آن را بهعنوان نتیجه بازگرداند. متد :meth:`~re.Pattern.finditer` دنبالهای از نمونههای :ref:`شیء تطبیق <match-objects>` را بهصورت یک :term:`پیمایشگر <iterator>` برمیگرداند::"
msgid ""
">>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')\n"
">>> iterator\n"
"<callable_iterator object at 0x...>\n"
">>> for match in iterator:\n"
"... print(match.span())\n"
"...\n"
"(0, 2)\n"
"(22, 24)\n"
"(29, 31)"
msgstr ""
">>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')\n"
">>> iterator\n"
"<callable_iterator object at 0x...>\n"
">>> for match in iterator:\n"
"... print(match.span())\n"
"...\n"
"(0, 2)\n"
"(22, 24)\n"
"(29, 31)"
msgid "Module-level functions"
msgstr "توابع سطح ماژول"
msgid "You don't have to create a pattern object and call its methods; the :mod:`re` module also provides top-level functions called :func:`~re.match`, :func:`~re.search`, :func:`~re.findall`, :func:`~re.sub`, and so forth. These functions take the same arguments as the corresponding pattern method with the RE string added as the first argument, and still return either ``None`` or a :ref:`match object <match-objects>` instance. ::"
msgstr "شما مجبور نیستید یک شیء الگو ایجاد کنید و متدهای آن را فراخوانی کنید؛ ماژول :mod:`re` همچنین توابع سطح بالایی به نامهای :func:`~re.match`، :func:`~re.search`، :func:`~re.findall`، :func:`~re.sub` و غیره ارائه میدهد. این توابع همان آرگومانهای متد متناظر الگو را، با اضافه شدن رشته RE بهعنوان اولین آرگومان، میپذیرند، و همچنان یا ``None`` یا نمونهای از :ref:`شیء تطبیق <match-objects>` را برمیگردانند. ::"
msgid ""
">>> print(re.match(r'From\\s+', 'Fromage amk'))\n"
"None\n"
">>> re.match(r'From\\s+', 'From amk Thu May 14 19:12:10 1998')\n"
"<re.Match object; span=(0, 5), match='From '>"
msgstr ""
">>> print(re.match(r'From\\s+', 'Fromage amk'))\n"
"None\n"
">>> re.match(r'From\\s+', 'From amk Thu May 14 19:12:10 1998')\n"
"<re.Match object; span=(0, 5), match='From '>"
msgid "Under the hood, these functions simply create a pattern object for you and call the appropriate method on it. They also store the compiled object in a cache, so future calls using the same RE won't need to parse the pattern again and again."
msgstr "در پشت صحنه، این توابع بهسادگی یک شیء الگو برای شما ایجاد میکنند و متد مناسب را روی آن فراخوانی میکنند. همچنین شیء کامپایلشده را در نهانگاه ذخیره میکنند، بنابراین فراخوانیهای آینده با استفاده از همان RE نیازی ندارند که الگو را دوباره و دوباره تجزیه کنند."
msgid "Should you use these module-level functions, or should you get the pattern and call its methods yourself? If you're accessing a regex within a loop, pre-compiling it will save a few function calls. Outside of loops, there's not much difference thanks to the internal cache."
msgstr "آیا باید از این توابع سطح ماژول استفاده کنید، یا باید خودتان الگو را دریافت کنید و متدهای آن را فراخوانی کنید؟ اگر در یک حلقه از یک عبارت باقاعده استفاده میکنید، از پیش کامپایل کردن آن باعث صرفهجویی در چند فراخوانی تابع میشود. خارج از حلقهها، به لطف نهانگاه داخلی تفاوت چندانی وجود ندارد."
msgid "Compilation flags"
msgstr "پرچمهای کامپایل"
msgid "Compilation flags let you modify some aspects of how regular expressions work. Flags are available in the :mod:`re` module under two names, a long name such as :const:`IGNORECASE` and a short, one-letter form such as :const:`I`. (If you're familiar with Perl's pattern modifiers, the one-letter forms use the same letters; the short form of :const:`re.VERBOSE` is :const:`re.X`, for example.) Multiple flags can be specified by bitwise OR-ing them; ``re.I | re.M`` sets both the :const:`I` and :const:`M` flags, for example."
msgstr "پرچمهای کامپایل به شما امکان میدهند برخی جنبههای نحوهی کار عبارات باقاعده را تغییر دهید. پرچمها در ماژول :mod:`re` با دو نام در دسترس هستند: نامی بلند مانند :const:`IGNORECASE` و صورتی کوتاه و تکحرفی مانند :const:`I`. (اگر با اصلاحکنندههای الگوی Perl آشنا هستید، صورتهای تکحرفی از همان حروف استفاده میکنند؛ برای مثال، صورت کوتاه :const:`re.VERBOSE` برابر :const:`re.X` است.) میتوان چند پرچم را با OR بیتی کردن آنها مشخص کرد؛ برای مثال، ``re.I | re.M`` هر دو پرچم :const:`I` و :const:`M` را تنظیم میکند."
msgid "Here's a table of the available flags, followed by a more detailed explanation of each one."
msgstr "در اینجا جدولی از پرچمهای موجود آمده است و در ادامه، توضیح دقیقتری برای هر یک ارائه میشود."
msgid "Flag"
msgstr "پرچم"
msgid "Meaning"
msgstr "معنی"
msgid ":const:`ASCII`, :const:`A`"
msgstr ":const:`ASCII`, :const:`A`"
msgid "Makes several escapes like ``\\w``, ``\\b``, ``\\s`` and ``\\d`` match only on ASCII characters with the respective property."
msgstr "باعث میشود چندین دنبالهی خنثیسازی مانند ``\\w``، ``\\b``، ``\\s`` و ``\\d`` فقط با نویسههای ASCII دارای ویژگی مربوطه مطابقت کنند."
msgid ":const:`DOTALL`, :const:`S`"
msgstr ":const:`DOTALL`, :const:`S`"
msgid "Make ``.`` match any character, including newlines."
msgstr "باعث میشود ``.`` با هر نویسهای، از جمله سطرهای جدید، تطبیق داده شود."
msgid ":const:`IGNORECASE`, :const:`I`"
msgstr ":const:`IGNORECASE`, :const:`I`"
msgid "Do case-insensitive matches."
msgstr "تطبیقهای بدون حساسیت به بزرگی و کوچکی حروف را انجام دهید."
msgid ":const:`LOCALE`, :const:`L`"
msgstr ":const:`LOCALE`, :const:`L`"
msgid "Do a locale-aware match."
msgstr "یک تطبیق آگاه از locale انجام دهید."
msgid ":const:`MULTILINE`, :const:`M`"
msgstr ":const:`MULTILINE`, :const:`M`"
msgid "Multi-line matching, affecting ``^`` and ``$``."
msgstr "تطبیق چندخطی، که بر ``^`` و ``$`` تأثیر میگذارد."
msgid ":const:`VERBOSE`, :const:`X` (for 'extended')"
msgstr ":const:`VERBOSE`، :const:`X` (برای «گسترده»)"
msgid "Enable verbose REs, which can be organized more cleanly and understandably."
msgstr "فعالسازی عبارتهای باقاعده خوانا (verbose REs)، که میتوان آنها را منظمتر و قابلفهمتر سازماندهی کرد."
msgid "Perform case-insensitive matching; character class and literal strings will match letters by ignoring case. For example, ``[A-Z]`` will match lowercase letters, too. Full Unicode matching also works unless the :const:`ASCII` flag is used to disable non-ASCII matches. When the Unicode patterns ``[a-z]`` or ``[A-Z]`` are used in combination with the :const:`IGNORECASE` flag, they will match the 52 ASCII letters and 4 additional non-ASCII letters: 'İ' (U+0130, Latin capital letter I with dot above), 'ı' (U+0131, Latin small letter dotless i), 'ſ' (U+017F, Latin small letter long s) and 'K' (U+212A, Kelvin sign). ``Spam`` will match ``'Spam'``, ``'spam'``, ``'spAM'``, or ``'ſpam'`` (the latter is matched only in Unicode mode). This lowercasing doesn't take the current locale into account; it will if you also set the :const:`LOCALE` flag."
msgstr "تطبیق بدون حساسیت به بزرگی و کوچکی حروف انجام میشود؛ کلاسهای نویسه و رشتههای لفظی، حروف را با چشمپوشی از بزرگی و کوچکی تطبیق میدهند. برای مثال، ``[A-Z]`` حروف کوچک را نیز تطبیق میدهد. تطبیق کامل یونیکد نیز کار میکند، مگر اینکه از پرچم :const:`ASCII` برای غیرفعالسازی تطبیقهای غیر ASCII استفاده شود. هنگامی که الگوهای یونیکد ``[a-z]`` یا ``[A-Z]`` به همراه پرچم :const:`IGNORECASE` استفاده شوند، آنها ۵۲ حرف ASCII و ۴ حرف غیر ASCII دیگر را تطبیق خواهند داد: 'İ' (U+0130، حرف بزرگ لاتین I با نقطه بالا)، 'ı' (U+0131، حرف کوچک لاتین i بدون نقطه)، 'ſ' (U+017F، حرف کوچک لاتین s بلند) و 'K' (U+212A، علامت کلوین). ``Spam`` با ``'Spam'``، ``'spam'``، ``'spAM'`` یا ``'ſpam'`` تطبیق خواهد داشت (مورد آخر فقط در حالت یونیکد تطبیق داده میشود). این تبدیل به حروف کوچک، locale فعلی را در نظر نمیگیرد؛ اگر پرچم :const:`LOCALE` را نیز تنظیم کنید، در نظر خواهد گرفت."
msgid "Make ``\\w``, ``\\W``, ``\\b``, ``\\B`` and case-insensitive matching dependent on the current locale instead of the Unicode database."
msgstr "تطبیق ``\\w``، ``\\W``، ``\\b``، ``\\B`` و تطبیق بدون حساسیت به بزرگی و کوچکی حروف را به جای پایگاه دادهی یونیکد، به locale جاری وابسته میکند."
msgid "Locales are a feature of the C library intended to help in writing programs that take account of language differences. For example, if you're processing encoded French text, you'd want to be able to write ``\\w+`` to match words, but ``\\w`` only matches the character class ``[A-Za-z]`` in bytes patterns; it won't match bytes corresponding to ``é`` or ``ç``. If your system is configured properly and a French locale is selected, certain C functions will tell the program that the byte corresponding to ``é`` should also be considered a letter. Setting the :const:`LOCALE` flag when compiling a regular expression will cause the resulting compiled object to use these C functions for ``\\w``; this is slower, but also enables ``\\w+`` to match French words as you'd expect. The use of this flag is discouraged in Python 3 as the locale mechanism is very unreliable, it only handles one \"culture\" at a time, and it only works with 8-bit locales. Unicode matching is already enabled by default in Python 3 for Unicode (str) patterns, and it is able to handle different locales/languages."
msgstr "locale ها قابلیتی از کتابخانهی C هستند که برای کمک به نوشتن برنامههایی در نظر گرفته شدهاند که تفاوتهای زبانی را در نظر میگیرند. برای مثال، اگر در حال پردازش متن فرانسویِ کدگذاریشده هستید، میخواهید بتوانید ``\\w+`` را برای تطبیق واژهها بنویسید، اما ``\\w`` در الگوهای بایتی فقط با کلاس نویسهی ``[A-Za-z]`` تطبیق میکند؛ بنابراین با بایتهای متناظر با ``é`` یا ``ç`` تطبیق نمیکند. اگر سامانهی شما بهدرستی پیکربندی شده باشد و یک locale فرانسوی انتخاب شده باشد، برخی تابعهای C به برنامه اعلام میکنند که بایت متناظر با ``é`` نیز باید یک نویسهی حرفی در نظر گرفته شود. تنظیم پرچم :const:`LOCALE` هنگام کامپایل یک عبارت باقاعده باعث میشود شیء کامپایلشدهی حاصل از این تابعهای C برای ``\\w`` استفاده کند؛ این کار کندتر است، اما همچنین باعث میشود ``\\w+`` همانطور که انتظار میرود با واژههای فرانسوی تطبیق کند. استفاده از این پرچم در پایتون ۳ توصیه نمیشود، زیرا سازوکار locale بسیار غیرقابلاعتماد است، در هر زمان فقط یک «فرهنگ» را مدیریت میکند و فقط با localeهای ۸بیتی کار میکند. تطبیق یونیکد در پایتون ۳ برای الگوهای یونیکدی (`str`) بهطور پیشفرض فعال است و میتواند localeها/زبانهای مختلف را مدیریت کند."
msgid "(``^`` and ``$`` haven't been explained yet; they'll be introduced in section :ref:`more-metacharacters`.)"
msgstr "(``^`` و ``$`` هنوز توضیح داده نشدهاند؛ آنها در بخش :ref:`more-metacharacters` معرفی خواهند شد.)"
msgid "Usually ``^`` matches only at the beginning of the string, and ``$`` matches only at the end of the string and immediately before the newline (if any) at the end of the string. When this flag is specified, ``^`` matches at the beginning of the string and at the beginning of each line within the string, immediately following each newline. Similarly, the ``$`` metacharacter matches either at the end of the string and at the end of each line (immediately preceding each newline)."
msgstr "معمولاً ``^`` تنها در ابتدای رشته تطابق دارد، و ``$`` تنها در پایان رشته و دقیقاً پیش از خط جدید (در صورت وجود) در پایان رشته تطابق دارد. هنگامی که این پرچم تعیین شده باشد، ``^`` در ابتدای رشته و در ابتدای هر خط درون رشته، دقیقاً پس از هر خط جدید، تطابق دارد. بهطور مشابه، فرانویسهی ``$`` یا در پایان رشته یا در پایان هر خط (دقیقاً پیش از هر خط جدید) تطابق دارد."
msgid "Makes the ``'.'`` special character match any character at all, including a newline; without this flag, ``'.'`` will match anything *except* a newline."
msgstr "باعث میشود نویسهی خاص ``'.'`` با هر نویسهای، از جمله خط جدید، مطابقت کند؛ بدون این پرچم، ``'.'`` با هر چیزی *بهجز* خط جدید مطابقت خواهد کرد."
msgid "Make ``\\w``, ``\\W``, ``\\b``, ``\\B``, ``\\s`` and ``\\S`` perform ASCII-only matching instead of full Unicode matching. This is only meaningful for Unicode patterns, and is ignored for byte patterns."
msgstr "باعث میشود ``\\w``، ``\\W``، ``\\b``، ``\\B``، ``\\s`` و ``\\S`` بهجای تطبیق کامل یونیکد، تطبیق فقط ASCII را انجام دهند. این موضوع فقط برای الگوهای یونیکدی معنادار است و برای الگوهای بایتی نادیده گرفته میشود."
msgid "This flag allows you to write regular expressions that are more readable by granting you more flexibility in how you can format them. When this flag has been specified, whitespace within the RE string is ignored, except when the whitespace is in a character class or preceded by an unescaped backslash; this lets you organize and indent the RE more clearly. This flag also lets you put comments within a RE that will be ignored by the engine; comments are marked by a ``'#'`` that's neither in a character class nor preceded by an unescaped backslash."
msgstr "این پرچم به شما امکان میدهد عبارتهای باقاعده خواناتری بنویسید، زیرا انعطافپذیری بیشتری در نحوه قالببندی آنها در اختیار شما قرار میدهد. هنگامی که این پرچم مشخص شده باشد، فضای سفید درون رشته عبارت باقاعده نادیده گرفته میشود، مگر وقتی که فضای سفید در یک کلاس نویسه باشد یا پیش از آن یک بکاسلش خنثینشده قرار داشته باشد؛ این امر به شما امکان میدهد عبارت باقاعده را واضحتر سازماندهی و تورفتگیگذاری کنید. این پرچم همچنین به شما امکان میدهد کامنتهایی را درون یک عبارت باقاعده قرار دهید که توسط موتور نادیده گرفته میشوند؛ کامنتها با یک ``'#'`` مشخص میشوند که نه در یک کلاس نویسه باشد و نه پیش از آن یک بکاسلش خنثینشده قرار داشته باشد."
msgid "For example, here's a RE that uses :const:`re.VERBOSE`; see how much easier it is to read? ::"
msgstr "برای مثال، در اینجا یک عبارت باقاعده آمده است که از :const:`re.VERBOSE` استفاده میکند؛ ببینید چقدر خواندن آن آسانتر است؟ ::"
msgid ""
"charref = re.compile(r\"\"\"\n"
" &[#] # Start of a numeric entity reference\n"
" (\n"
" 0[0-7]+ # Octal form\n"
" | [0-9]+ # Decimal form\n"
" | x[0-9a-fA-F]+ # Hexadecimal form\n"
" )\n"
" ; # Trailing semicolon\n"
"\"\"\", re.VERBOSE)"
msgstr ""
"charref = re.compile(r\"\"\"\n"
" &[#] # Start of a numeric entity reference\n"
" (\n"
" 0[0-7]+ # Octal form\n"
" | [0-9]+ # Decimal form\n"
" | x[0-9a-fA-F]+ # Hexadecimal form\n"
" )\n"
" ; # Trailing semicolon\n"
"\"\"\", re.VERBOSE)"
msgid "Without the verbose setting, the RE would look like this::"
msgstr "بدون تنظیم verbose، RE به این شکل خواهد بود::"
msgid ""
"charref = re.compile(\"&#(0[0-7]+\"\n"
" \"|[0-9]+\"\n"
" \"|x[0-9a-fA-F]+);\")"
msgstr ""
"charref = re.compile(\"&#(0[0-7]+\"\n"
" \"|[0-9]+\"\n"
" \"|x[0-9a-fA-F]+);\")"
msgid "In the above example, Python's automatic concatenation of string literals has been used to break up the RE into smaller pieces, but it's still more difficult to understand than the version using :const:`re.VERBOSE`."
msgstr "در مثال بالا، از الحاق خودکار رشتههای لفظی در پایتون برای شکستن عبارت باقاعده به قطعات کوچکتر استفاده شده است، اما درک آن هنوز از نسخهای که از :const:`re.VERBOSE` استفاده میکند، دشوارتر است."
msgid "More pattern power"
msgstr "قدرت بیشتر الگوها"
msgid "So far we've only covered a part of the features of regular expressions. In this section, we'll cover some new metacharacters, and how to use groups to retrieve portions of the text that was matched."
msgstr "تاکنون تنها بخشی از قابلیتهای عبارتهای باقاعده را بررسی کردهایم. در این بخش، برخی فرانویسههای جدید و چگونگی استفاده از گروهها برای بازیابی بخشهایی از متنی که تطبیق داده شده است را بررسی خواهیم کرد."
msgid "More metacharacters"
msgstr "فرانویسههای بیشتر"
msgid "There are some metacharacters that we haven't covered yet. Most of them will be covered in this section."
msgstr "هنوز برخی از فرانویسهها پوشش داده نشدهاند. بیشتر آنها در این بخش پوشش داده خواهند شد."
msgid "Some of the remaining metacharacters to be discussed are :dfn:`zero-width assertions`. They don't cause the engine to advance through the string; instead, they consume no characters at all, and simply succeed or fail. For example, ``\\b`` is an assertion that the current position is located at a word boundary; the position isn't changed by the ``\\b`` at all. This means that zero-width assertions should never be repeated, because if they match once at a given location, they can obviously be matched an infinite number of times."
msgstr "برخی از فرانویسههای باقیمانده که مورد بحث قرار خواهند گرفت، :dfn:` شرطهای با عرض صفر <zero-width assertions>` هستند. آنها باعث نمیشوند موتور در رشته پیشروی کند؛ در عوض، اصلاً هیچ نویسهای مصرف نمیکنند و صرفاً موفق یا ناموفق میشوند. برای مثال، ``\\b`` ادعایی است مبنی بر اینکه موقعیت فعلی در یک مرز کلمه قرار دارد؛ موقعیت بههیچوجه توسط ``\\b`` تغییر نمیکند. این بدان معناست که شرطهای با عرض صفر هرگز نباید تکرار شوند، زیرا اگر یک بار در یک مکان مشخص تطابق داشته باشند، بدیهی است که میتوانند بینهایت بار تطابق یابند."
msgid "``|``"
msgstr "``|``"
msgid "Alternation, or the \"or\" operator. If *A* and *B* are regular expressions, ``A|B`` will match any string that matches either *A* or *B*. ``|`` has very low precedence in order to make it work reasonably when you're alternating multi-character strings. ``Crow|Servo`` will match either ``'Crow'`` or ``'Servo'``, not ``'Cro'``, a ``'w'`` or an ``'S'``, and ``'ervo'``."
msgstr "جایگزینی، یا عملگر «یا». اگر *A* و *B* عبارتهای باقاعده باشند، ``A|B`` با هر رشتهای که با *A* یا *B* مطابقت داشته باشد، مطابقت میکند. ``|`` اولویت بسیار پایینی دارد تا هنگام جایگزینی بین رشتههای چند نویسهای بهطور معقولی کار کند. ``Crow|Servo`` با ``'Crow'`` یا ``'Servo'`` مطابقت میکند، نه با ``'Cro'``، یک ``'w'`` یا یک ``'S'``، و ``'ervo'``."
msgid "To match a literal ``'|'``, use ``\\|``, or enclose it inside a character class, as in ``[|]``."
msgstr "برای تطبیق ``'|'`` بهصورت لفظی، از ``\\|`` استفاده کنید، یا آن را داخل یک کلاس نویسه قرار دهید، مانند ``[|]``."
msgid "``^``"
msgstr "``^``"
msgid "Matches at the beginning of lines. Unless the :const:`MULTILINE` flag has been set, this will only match at the beginning of the string. In :const:`MULTILINE` mode, this also matches immediately after each newline within the string."
msgstr "در ابتدای سطرها تطابق مییابد. مگر اینکه پرچم :const:`MULTILINE` تنظیم شده باشد، این فقط در ابتدای رشته تطابق خواهد یافت. در حالت :const:`MULTILINE`، این بلافاصله پس از هر خط جدید در داخل رشته نیز تطابق مییابد."
msgid "For example, if you wish to match the word ``From`` only at the beginning of a line, the RE to use is ``^From``. ::"
msgstr "برای مثال، اگر میخواهید کلمه ``From`` فقط در ابتدای یک خط تطابق داده شود، عبارت باقاعدهای که باید استفاده کنید ``^From`` است. ::"
msgid ""
">>> print(re.search('^From', 'From Here to Eternity'))\n"
"<re.Match object; span=(0, 4), match='From'>\n"
">>> print(re.search('^From', 'Reciting From Memory'))\n"
"None"
msgstr ""
">>> print(re.search('^From', 'From Here to Eternity'))\n"
"<re.Match object; span=(0, 4), match='From'>\n"
">>> print(re.search('^From', 'Reciting From Memory'))\n"
"None"
msgid "To match a literal ``'^'``, use ``\\^``."
msgstr "برای تطبیق یک ``'^'`` لفظی، از ``\\^`` استفاده کنید."
msgid "``$``"
msgstr "``$``"
msgid "Matches at the end of a line, which is defined as either the end of the string, or any location followed by a newline character. ::"
msgstr "در پایان یک خط تطابق پیدا میکند؛ پایان خط بهصورت پایان رشته یا هر مکانی که پس از آن یک نویسهی خط جدید باشد تعریف میشود. ::"
msgid ""
">>> print(re.search('}$', '{block}'))\n"
"<re.Match object; span=(6, 7), match='}'>\n"
">>> print(re.search('}$', '{block} '))\n"
"None\n"
">>> print(re.search('}$', '{block}\\n'))\n"
"<re.Match object; span=(6, 7), match='}'>"
msgstr ""
">>> print(re.search('}$', '{block}'))\n"
"<re.Match object; span=(6, 7), match='}'>\n"
">>> print(re.search('}$', '{block} '))\n"
"None\n"
">>> print(re.search('}$', '{block}\\n'))\n"
"<re.Match object; span=(6, 7), match='}'>"
msgid "To match a literal ``'$'``, use ``\\$`` or enclose it inside a character class, as in ``[$]``."
msgstr "برای تطبیق ``'$'`` بهصورت لفظی، از ``\\$`` استفاده کنید یا آن را درون یک کلاس نویسه قرار دهید، مانند ``[$]``."
msgid "``\\A``"
msgstr "``\\A``"
msgid "Matches only at the start of the string. When not in :const:`MULTILINE` mode, ``\\A`` and ``^`` are effectively the same. In :const:`MULTILINE` mode, they're different: ``\\A`` still matches only at the beginning of the string, but ``^`` may match at any location inside the string that follows a newline character."
msgstr "فقط در ابتدای رشته مطابقت میکند. هنگامی که حالت :const:`MULTILINE` فعال نباشد، ``\\A`` و ``^`` عملاً یکسان هستند. در حالت :const:`MULTILINE`، این دو متفاوت هستند: ``\\A`` همچنان فقط در ابتدای رشته مطابقت میکند، اما ``^`` ممکن است در هر جای داخل رشته که پس از یک نویسهی خط جدید قرار داشته باشد، مطابقت کند."
msgid "``\\z``"
msgstr "``\\z``"
msgid "Matches only at the end of the string."
msgstr "فقط در انتهای رشته مطابقت میکند."
msgid "``\\Z``"
msgstr "``\\Z``"
msgid "The same as ``\\z``. For compatibility with old Python versions."
msgstr "همان ``\\z`` است. برای سازگاری با نسخههای قدیمی پایتون."
msgid "``\\b``"
msgstr "``\\b``"
msgid "Word boundary. This is a zero-width assertion that matches only at the beginning or end of a word. A word is defined as a sequence of alphanumeric characters, so the end of a word is indicated by whitespace or a non-alphanumeric character."
msgstr "مرز کلمه. این یک شرط با عرض صفر (zero-width assertion) است که فقط در آغاز یا پایان یک کلمه تطابق مییابد. یک کلمه بهعنوان دنبالهای از نویسههای الفبایی-عددی تعریف میشود، بنابراین پایان یک کلمه با فضای خالی یا نویسهای غیرالفبایی-عددی مشخص میشود."
msgid "The following example matches ``class`` only when it's a complete word; it won't match when it's contained inside another word. ::"
msgstr "مثال زیر فقط زمانی ``class`` را تطبیق میدهد که یک کلمه کامل باشد؛ وقتی درون کلمهای دیگر قرار داشته باشد، تطبیق داده نخواهد شد. ::"
msgid ""
">>> p = re.compile(r'\\bclass\\b')\n"
">>> print(p.search('no class at all'))\n"
"<re.Match object; span=(3, 8), match='class'>\n"
">>> print(p.search('the declassified algorithm'))\n"
"None\n"
">>> print(p.search('one subclass is'))\n"
"None"
msgstr ""
">>> p = re.compile(r'\\bclass\\b')\n"
">>> print(p.search('no class at all'))\n"
"<re.Match object; span=(3, 8), match='class'>\n"
">>> print(p.search('the declassified algorithm'))\n"
"None\n"
">>> print(p.search('one subclass is'))\n"
"None"
msgid "There are two subtleties you should remember when using this special sequence. First, this is the worst collision between Python's string literals and regular expression sequences. In Python's string literals, ``\\b`` is the backspace character, ASCII value 8. If you're not using raw strings, then Python will convert the ``\\b`` to a backspace, and your RE won't match as you expect it to. The following example looks the same as our previous RE, but omits the ``'r'`` in front of the RE string. ::"
msgstr "دو نکتهی ظریف وجود دارد که باید هنگام استفاده از این دنبالهی خاص آنها را بهخاطر بسپارید. اول، این بدترین تداخل میان رشتههای لفظی پایتون و دنبالههای عبارت باقاعده است. در رشتههای لفظی پایتون، ``\\b`` نویسهی پسبر (backspace) با مقدار ASCII ۸ است. اگر از رشتههای خام استفاده نمیکنید، پایتون ``\\b`` را به یک پسبر (backspace) تبدیل میکند و عبارت باقاعدهی شما آنطور که انتظار دارید تطابق نخواهد کرد. مثال زیر همانند عبارت باقاعدهی قبلی ما به نظر میرسد، اما ``'r'`` را از ابتدای رشتهی عبارت باقاعده حذف میکند. ::"
msgid ""
">>> p = re.compile('\\bclass\\b')\n"
">>> print(p.search('no class at all'))\n"
"None\n"
">>> print(p.search('\\b' + 'class' + '\\b'))\n"
"<re.Match object; span=(0, 7), match='\\x08class\\x08'>"
msgstr ""
">>> p = re.compile('\\bclass\\b')\n"
">>> print(p.search('no class at all'))\n"
"None\n"
">>> print(p.search('\\b' + 'class' + '\\b'))\n"
"<re.Match object; span=(0, 7), match='\\x08class\\x08'>"
msgid "Second, inside a character class, where there's no use for this assertion, ``\\b`` represents the backspace character, for compatibility with Python's string literals."
msgstr "دوم، داخل یک کلاس نویسه، جایی که این ادعا کاربردی ندارد، ``\\b`` نشاندهندهی نویسهی پسبر (backspace) است، برای سازگاری با مقادیر لفظی رشتهای پایتون."
msgid "``\\B``"
msgstr "``\\B``"
msgid "Another zero-width assertion, this is the opposite of ``\\b``, only matching when the current position is not at a word boundary."
msgstr "یک شرط با عرض صفر (zero-width assertion) دیگر، این متضاد ``\\b`` است و فقط زمانی مطابقت میکند که موقعیت فعلی در مرز واژه نباشد."
msgid "Grouping"
msgstr "گروهبندی"
msgid "Frequently you need to obtain more information than just whether the RE matched or not. Regular expressions are often used to dissect strings by writing a RE divided into several subgroups which match different components of interest. For example, an RFC-822 header line is divided into a header name and a value, separated by a ``':'``, like this:"
msgstr "اغلب نیاز دارید اطلاعات بیشتری بیش از صرفاً اینکه آیا عبارت باقاعده تطابق داشته است یا خیر، به دست آورید. از عبارات باقاعده اغلب برای تجزیه رشتهها با نوشتن یک عبارت باقاعده تقسیمشده به چند زیرگروه که با اجزای مختلف مورد نظر تطابق دارند، استفاده میشود. برای مثال، یک خط سرآیند RFC-822 به یک نام سرآیند و یک مقدار تقسیم میشود که با یک ``':'`` از هم جدا شدهاند؛ مانند این:"
msgid ""
"From: author@example.com\n"
"User-Agent: Thunderbird 1.5.0.9 (X11/20061227)\n"
"MIME-Version: 1.0\n"
"To: editor@example.com"
msgstr ""
"From: author@example.com\n"
"User-Agent: Thunderbird 1.5.0.9 (X11/20061227)\n"
"MIME-Version: 1.0\n"
"To: editor@example.com"
msgid "This can be handled by writing a regular expression which matches an entire header line, and has one group which matches the header name, and another group which matches the header's value."
msgstr "این مورد را میتوان با نوشتن یک عبارت باقاعده مدیریت کرد که با کل خط سرآیند تطابق دارد و دارای یک گروه است که با نام سرآیند تطابق دارد، و گروه دیگری که با مقدار سرآیند تطابق دارد."
msgid "Groups are marked by the ``'('``, ``')'`` metacharacters. ``'('`` and ``')'`` have much the same meaning as they do in mathematical expressions; they group together the expressions contained inside them, and you can repeat the contents of a group with a quantifier, such as ``*``, ``+``, ``?``, or ``{m,n}``. For example, ``(ab)*`` will match zero or more repetitions of ``ab``. ::"
msgstr "گروهها با فرانویسههای ``'('`` و ``')'`` مشخص میشوند. ``'('`` و ``')'`` تقریباً همان معنایی را دارند که در عبارات ریاضی دارند؛ آنها عبارات درون خود را با هم گروهبندی میکنند، و شما میتوانید محتوای یک گروه را با یک کمیتگذار (quantifier)، مانند ``*``، ``+``، ``?`` یا ``{m,n}`` تکرار کنید. برای مثال، ``(ab)*`` با صفر یا چند تکرار از ``ab`` مطابقت میکند. ::"
msgid ""
">>> p = re.compile('(ab)*')\n"
">>> print(p.match('ababababab').span())\n"
"(0, 10)"
msgstr ""
">>> p = re.compile('(ab)*')\n"
">>> print(p.match('ababababab').span())\n"
"(0, 10)"
msgid "Groups indicated with ``'('``, ``')'`` also capture the starting and ending index of the text that they match; this can be retrieved by passing an argument to :meth:`~re.Match.group`, :meth:`~re.Match.start`, :meth:`~re.Match.end`, and :meth:`~re.Match.span`. Groups are numbered starting with 0. Group 0 is always present; it's the whole RE, so :ref:`match object <match-objects>` methods all have group 0 as their default argument. Later we'll see how to express groups that don't capture the span of text that they match. ::"
msgstr "گروههای مشخصشده با ``'('`` و ``')'`` همچنین اندیسهای آغاز و پایان متنی را که تطبیق میدهند ضبط میکنند؛ این را میتوان با ارسال یک آرگومان به :meth:`~re.Match.group`، :meth:`~re.Match.start`، :meth:`~re.Match.end` و :meth:`~re.Match.span` بازیابی کرد. گروهها از ۰ شمارهگذاری میشوند. گروه ۰ همیشه وجود دارد؛ این گروه کل RE است، بنابراین تمام متدهای :ref:`شیء تطبیق <match-objects>` گروه ۰ را بهعنوان آرگومان پیشفرض خود دارند. در ادامه خواهیم دید که چگونه گروههایی را بیان کنیم که بازهی متنی را که تطبیق میدهند ضبط نمیکنند. ::"
msgid ""
">>> p = re.compile('(a)b')\n"
">>> m = p.match('ab')\n"
">>> m.group()\n"
"'ab'\n"
">>> m.group(0)\n"
"'ab'"
msgstr ""
">>> p = re.compile('(a)b')\n"
">>> m = p.match('ab')\n"
">>> m.group()\n"
"'ab'\n"
">>> m.group(0)\n"
"'ab'"
msgid "Subgroups are numbered from left to right, from 1 upward. Groups can be nested; to determine the number, just count the opening parenthesis characters, going from left to right. ::"
msgstr "زیرگروهها از چپ به راست، از ۱ به بعد شمارهگذاری میشوند. گروهها میتوانند تودرتو باشند؛ برای تعیین شماره، کافی است نویسههای پرانتز باز را از چپ به راست بشمارید. ::"
msgid ""
">>> p = re.compile('(a(b)c)d')\n"
">>> m = p.match('abcd')\n"
">>> m.group(0)\n"
"'abcd'\n"
">>> m.group(1)\n"
"'abc'\n"
">>> m.group(2)\n"
"'b'"
msgstr ""
">>> p = re.compile('(a(b)c)d')\n"
">>> m = p.match('abcd')\n"
">>> m.group(0)\n"
"'abcd'\n"
">>> m.group(1)\n"
"'abc'\n"
">>> m.group(2)\n"
"'b'"
msgid ":meth:`~re.Match.group` can be passed multiple group numbers at a time, in which case it will return a tuple containing the corresponding values for those groups. ::"
msgstr "میتوان چندین شماره گروه را بهصورت همزمان به :meth:`~re.Match.group` ارسال کرد، که در این صورت یک تاپل شامل مقادیر متناظر برای آن گروهها برمیگرداند. ::"
msgid ""
">>> m.group(2,1,2)\n"
"('b', 'abc', 'b')"
msgstr ""
">>> m.group(2,1,2)\n"
"('b', 'abc', 'b')"
msgid "The :meth:`~re.Match.groups` method returns a tuple containing the strings for all the subgroups, from 1 up to however many there are. ::"
msgstr "متد :meth:`~re.Match.groups` یک تاپل شامل رشتههای تمام زیرگروهها، از ۱ تا هر تعداد که وجود داشته باشد، برمیگرداند. ::"
msgid ""
">>> m.groups()\n"
"('abc', 'b')"
msgstr ""
">>> m.groups()\n"
"('abc', 'b')"
msgid "Backreferences in a pattern allow you to specify that the contents of an earlier capturing group must also be found at the current location in the string. For example, ``\\1`` will succeed if the exact contents of group 1 can be found at the current position, and fails otherwise. Remember that Python's string literals also use a backslash followed by numbers to allow including arbitrary characters in a string, so be sure to use a raw string when incorporating backreferences in a RE."
msgstr "بازارجاعها در یک الگو به شما امکان میدهند مشخص کنید که محتوای یک گروه ثبتکننده پیشین نیز باید در موقعیت فعلی در رشته یافت شود. برای مثال، اگر محتوای دقیق گروه ۱ در موقعیت فعلی یافت شود، ``\\1`` موفق میشود و در غیر این صورت شکست میخورد. به یاد داشته باشید که مقادیر لفظی رشته در پایتون نیز از یک بکاسلش و سپس اعداد برای امکان گنجاندن نویسههای دلخواه در رشته استفاده میکنند، بنابراین هنگام بهکارگیری بازارجاعها در یک RE، حتماً از یک رشته خام استفاده کنید."
msgid "For example, the following RE detects doubled words in a string. ::"
msgstr "برای مثال، عبارت باقاعده زیر کلمات تکراری در یک رشته را تشخیص میدهد. ::"
msgid ""
">>> p = re.compile(r'\\b(\\w+)\\s+\\1\\b')\n"
">>> p.search('Paris in the the spring').group()\n"
"'the the'"
msgstr ""
">>> p = re.compile(r'\\b(\\w+)\\s+\\1\\b')\n"
">>> p.search('Paris in the the spring').group()\n"
"'the the'"
msgid "Backreferences like this aren't often useful for just searching through a string --- there are few text formats which repeat data in this way --- but you'll soon find out that they're *very* useful when performing string substitutions."
msgstr "اینگونه بازارجاعها (backreferences) معمولاً صرفاً برای جستوجو در یک رشته چندان مفید نیستند --- قالبهای متنی کمی وجود دارند که دادهها را به این شکل تکرار میکنند --- اما بهزودی متوجه خواهید شد که هنگام انجام جایگزینیهای رشتهای *بسیار* مفید هستند."
msgid "Non-capturing and named groups"
msgstr "گروههای غیرثبتکننده و نامدار"
msgid "Elaborate REs may use many groups, both to capture substrings of interest, and to group and structure the RE itself. In complex REs, it becomes difficult to keep track of the group numbers. There are two features which help with this problem. Both of them use a common syntax for regular expression extensions, so we'll look at that first."
msgstr "عبارات باقاعده مفصل ممکن است از گروههای زیادی استفاده کنند، هم برای گرفتن زیررشتههای موردنظر و هم برای گروهبندی و ساختاردهی خود عبارت باقاعده. در عبارات باقاعده پیچیده، پیگیری شمارههای گروه دشوار میشود. دو قابلیت وجود دارند که به حل این مشکل کمک میکنند. هر دوی آنها از یک سینتکس مشترک برای افزونههای عبارت باقاعده استفاده میکنند، بنابراین ابتدا آن را بررسی خواهیم کرد."
msgid "Perl 5 is well known for its powerful additions to standard regular expressions. For these new features the Perl developers couldn't choose new single-keystroke metacharacters or new special sequences beginning with ``\\`` without making Perl's regular expressions confusingly different from standard REs. If they chose ``&`` as a new metacharacter, for example, old expressions would be assuming that ``&`` was a regular character and wouldn't have escaped it by writing ``\\&`` or ``[&]``."
msgstr "Perl 5 به دلیل افزودنیهای قدرتمندش به عبارتهای باقاعده استاندارد بهخوبی شناخته شده است. برای این قابلیتهای جدید، توسعهدهندگان Perl نمیتوانستند متانویسههای تککلیدی جدید یا دنبالههای خاص جدیدی را که با ``\\`` آغاز میشوند انتخاب کنند، بدون آنکه عبارتهای باقاعده Perl را بهشکلی گیجکننده از REهای استاندارد متفاوت کنند. برای مثال، اگر آنها ``&`` را بهعنوان یک متانویسه جدید انتخاب میکردند، عبارتهای قدیمی فرض میکردند که ``&`` یک نویسه معمولی است و آن را با نوشتن ``\\&`` یا ``[&]`` خنثی نمیکردند."
msgid "The solution chosen by the Perl developers was to use ``(?...)`` as the extension syntax. ``?`` immediately after a parenthesis was a syntax error because the ``?`` would have nothing to repeat, so this didn't introduce any compatibility problems. The characters immediately after the ``?`` indicate what extension is being used, so ``(?=foo)`` is one thing (a positive lookahead assertion) and ``(?:foo)`` is something else (a non-capturing group containing the subexpression ``foo``)."
msgstr "راهحلی که توسعهدهندگان Perl انتخاب کردند، استفاده از ``(?...)`` بهعنوان سینتکس گسترش بود. ``?`` بلافاصله پس از یک پرانتز یک خطای سینتکسی بود، زیرا ``?`` هیچ چیزی برای تکرار نداشت؛ بنابراین این موضوع هیچ مشکل سازگاریای ایجاد نکرد. نویسههای بلافاصله پس از ``?`` نشان میدهند که کدام گسترش استفاده میشود، بنابراین ``(?=foo)`` یک چیز است (یک ادعای پیشنگر مثبت (positive lookahead assertion)) و ``(?:foo)`` چیز دیگری است (یک گروه غیرثبتکننده (non-capturing group) شامل زیرعبارت ``foo``)."
msgid "Python supports several of Perl's extensions and adds an extension syntax to Perl's extension syntax. If the first character after the question mark is a ``P``, you know that it's an extension that's specific to Python."
msgstr "پایتون از چندین افزونهی پرل پشتیبانی میکند و یک سینتکس افزونه را به سینتکس افزونهی پرل اضافه میکند. اگر اولین نویسه پس از علامت سؤال ``P`` باشد، میدانید که این یک افزونهی مختص پایتون است."
msgid "Now that we've looked at the general extension syntax, we can return to the features that simplify working with groups in complex REs."
msgstr "اکنون که سینتکس کلی گسترش را بررسی کردیم، میتوانیم به قابلیتهایی بازگردیم که کار با گروهها را در عبارات باقاعدهی پیچیده ساده میکنند."
msgid "Sometimes you'll want to use a group to denote a part of a regular expression, but aren't interested in retrieving the group's contents. You can make this fact explicit by using a non-capturing group: ``(?:...)``, where you can replace the ``...`` with any other regular expression. ::"
msgstr "گاهی ممکن است بخواهید از یک گروه برای مشخص کردن بخشی از یک عبارت باقاعده استفاده کنید، اما مایل به بازیابی محتوای گروه نباشید. میتوانید این موضوع را با استفاده از یک گروه غیرثبتکننده (non-capturing group) بهصراحت بیان کنید: ``(?:...)``، که در آن میتوانید ``...`` را با هر عبارت باقاعده دیگری جایگزین کنید. ::"
msgid ""
">>> m = re.match(\"([abc])+\", \"abc\")\n"
">>> m.groups()\n"
"('c',)\n"
">>> m = re.match(\"(?:[abc])+\", \"abc\")\n"
">>> m.groups()\n"
"()"
msgstr ""
">>> m = re.match(\"([abc])+\", \"abc\")\n"
">>> m.groups()\n"
"('c',)\n"
">>> m = re.match(\"(?:[abc])+\", \"abc\")\n"
">>> m.groups()\n"
"()"
msgid "Except for the fact that you can't retrieve the contents of what the group matched, a non-capturing group behaves exactly the same as a capturing group; you can put anything inside it, repeat it with a repetition metacharacter such as ``*``, and nest it within other groups (capturing or non-capturing). ``(?:...)`` is particularly useful when modifying an existing pattern, since you can add new groups without changing how all the other groups are numbered. It should be mentioned that there's no performance difference in searching between capturing and non-capturing groups; neither form is any faster than the other."
msgstr "بهجز این واقعیت که نمیتوانید محتوای آنچه را که گروه با آن مطابقت کرده است بازیابی کنید، گروه غیرثبتکننده دقیقاً مانند گروه ثبتکننده رفتار میکند؛ میتوانید هر چیزی را درون آن قرار دهید، آن را با یک فرانویسهی تکرار مانند ``*`` تکرار کنید و آن را درون گروههای دیگر (ثبتکننده یا غیرثبتکننده) تودرتو کنید. ``(?:...)`` بهویژه هنگام تغییر یک الگوی موجود مفید است، زیرا میتوانید بدون آنکه نحوهی شمارهگذاری همهی گروههای دیگر تغییر کند، گروههای جدیدی اضافه کنید. لازم است ذکر شود که هیچ تفاوت عملکردی در جستجو میان گروههای ثبتکننده و غیرثبتکننده وجود ندارد؛ هیچیک از این دو شکل سریعتر از دیگری نیست."
msgid "A more significant feature is named groups: instead of referring to them by numbers, groups can be referenced by a name."
msgstr "ویژگی مهمتر، گروههای نامگذاریشده است: بهجای ارجاع به آنها با شمارهها، میتوان گروهها را با یک نام ارجاع داد."
msgid "The syntax for a named group is one of the Python-specific extensions: ``(?P<name>...)``. *name* is, obviously, the name of the group. Named groups behave exactly like capturing groups, and additionally associate a name with a group. The :ref:`match object <match-objects>` methods that deal with capturing groups all accept either integers that refer to the group by number or strings that contain the desired group's name. Named groups are still given numbers, so you can retrieve information about a group in two ways::"
msgstr "سینتکس یک گروه نامدار یکی از افزونههای خاص پایتون است: ``(?P<name>...)``. *name*، همانطور که پیداست، نام گروه است. گروههای نامدار دقیقاً مانند گروههای ثبتکننده رفتار میکنند و علاوه بر این، نامی را به یک گروه مرتبط میسازند. متدهای :ref:`شیء تطبیق <match-objects>` که با گروههای ثبتکننده سروکار دارند، همگی یا اعداد صحیحی را میپذیرند که با شماره به گروه ارجاع میدهند یا رشتههایی را که شامل نام گروه موردنظر هستند. گروههای نامدار همچنان شمارهگذاری میشوند، بنابراین میتوانید اطلاعات مربوط به یک گروه را به دو روش بازیابی کنید::"
msgid ""
">>> p = re.compile(r'(?P<word>\\b\\w+\\b)')\n"
">>> m = p.search( '(((( Lots of punctuation )))' )\n"
">>> m.group('word')\n"
"'Lots'\n"
">>> m.group(1)\n"
"'Lots'"
msgstr ""
">>> p = re.compile(r'(?P<word>\\b\\w+\\b)')\n"
">>> m = p.search( '(((( Lots of punctuation )))' )\n"
">>> m.group('word')\n"
"'Lots'\n"
">>> m.group(1)\n"
"'Lots'"
msgid "Additionally, you can retrieve named groups as a dictionary with :meth:`~re.Match.groupdict`::"
msgstr "علاوه بر این، میتوانید گروههای نامگذاریشده را با :meth:`~re.Match.groupdict` بهعنوان یک دیکشنری بازیابی کنید::"
msgid ""
">>> m = re.match(r'(?P<first>\\w+) (?P<last>\\w+)', 'Jane Doe')\n"
">>> m.groupdict()\n"