File: perlrebackslash.html

package info (click to toggle)
perl-doc-html 5.26.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 39,400 kB
  • sloc: xml: 36; makefile: 7
file content (1082 lines) | stat: -rw-r--r-- 77,398 bytes parent folder | download
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>perlrebackslash - perldoc.perl.org</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta http-equiv="Content-Language" content="en-gb">
  <link rel="search" type="application/opensearchdescription+xml" title="Search perldoc.perl.org" href="/static/search.xml"/>
  <link href="static/css-20100830.css" rel="stylesheet" rev="stylesheet" type="text/css" media="screen">
  <link href="static/exploreperl.css" rel="stylesheet" rev="stylesheet" type="text/css">
</head>

<body onLoad="perldoc.startup();" onPageShow="if (event.persisted) perldoc.startup();">
    <div id="page">
      
      <div id="header">
	<div id="homepage_link">
	  <a href="index.html"></a>
	</div>
	<div id="strapline">
	  Perl Programming Documentation
	</div>
	<div id="download_link" class="download">
	  <a href="http://www.perl.org/get.html">Download Perl</a>
	</div>
	<div id="explore_link" class="download">
	  <a id="explore_anchor" href="#">Explore</a>
	</div>
      </div>
      
      <div id="body">
        <div id="left_column">
          <div class="side_group">
            
	    <div class="side_panel doc_panel">
              <p>Manual</p>
              <ul>
                <li><a href="index-overview.html">Overview</a>
                <li><a href="index-tutorials.html">Tutorials</a>
                <li><a href="index-faq.html">FAQs</a>
                <li><a href="index-history.html">History / Changes</a>
                <li><a href="index-licence.html">License</a>
              </ul>
            </div>
            <div class="side_panel doc_panel">
              <p>Reference</p>
              <ul>
                <li><a href="index-language.html">Language</a>
                <li><a href="index-functions.html">Functions</a>
                <li><a href="perlop.html">Operators</a>
                <li><a href="perlvar.html">Special Variables</a>
                <li><a href="index-pragmas.html">Pragmas</a>
                <li><a href="index-utilities.html">Utilities</a>
                <li><a href="index-internals.html">Internals</a>
                <li><a href="index-platforms.html">Platform Specific</a>
              </ul>
            </div>
            <div class="side_panel doc_panel">
              <p>Modules</p>
              <ul>
		<li>
		
                
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		
                  
		
		
                    <a href="index-modules-A.html">A</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-B.html">B</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-C.html">C</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-D.html">D</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-E.html">E</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-F.html">F</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-G.html">G</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-H.html">H</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-I.html">I</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-L.html">L</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-M.html">M</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-N.html">N</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-O.html">O</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-P.html">P</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-S.html">S</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-T.html">T</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-U.html">U</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-X.html">X</a>
                    
                
              </ul>
            </div>
            
	      <div class="side_panel doc_panel">
		<p>Tools</p>
		<ul>
		  <li><a href="preferences.html">Preferences</a>
		</ul>
	      </div>
            
          </div>
        </div>
        <div id="centre_column">
          <div id="content_header">
            <div id="title_bar">
              <div id="page_name">
                <h1>perlrebackslash</h1>
              </div>
              <div id="perl_version">
                Perl 5 version 26.0 documentation
              </div>
              <div class="page_links" id="page_links_top">
                <a href="#" onClick="toolbar.goToTop();return false;">Go to top</a>
		
              </div>
	      <div class="page_links" id="page_links_bottom">
		
                  <a href="#" id="page_index_toggle">Show page index</a> &bull;
		
                <a href="#" id="recent_pages_toggle">Show recent pages</a>		
	      </div>
	      <div id="search_form">
		<form action="search.html" method="GET" id="search">
		  <input type="text" name="q" id="search_box" alt="Search">
		</form>
	      </div>
            </div>
            <div id="breadcrumbs">
                
    <a href="index.html">Home</a> &gt;
    
      
        <a href="index-language.html">Language reference</a> &gt;
      
    
    perlrebackslash
  

            </div>
          </div>
          <div id="content_body">
	    <!--[if lt IE 7]>
 <div class="noscript">
   <p>
     <strong>It looks like you're using Internet Explorer 6. This is a very old
     browser which does not offer full support for modern websites.</strong>
   </p>
   <p>
     Unfortunately this means that this website will not work on
     your computer.
   </p>
   <p>
     Don't miss out though! To view the site (and get a better experience from
     many other websites), simply upgrade to
     <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet
Explorer 8</a>
     or download an alternative browser such as
     <a href="http://www.mozilla.com/en-US/firefox/firefox.html">Firefox</a>,
     <a href="http://www.apple.com/safari/download/">Safari</a>, or
     <a href="http://www.google.co.uk/chrome">Google Chrome</a>.
   </p>
   <p>
     All of these browsers are free. If you're using a PC at work, you may
     need to contact your IT administrator.
   </p>
 </div>
<![endif]-->
	    <noscript>
	      <div class="noscript">
	      <p>
                <strong>Please note: Many features of this site require JavaScript. You appear to have JavaScript disabled,
	        or are running a non-JavaScript capable web browser.</strong>
	      </p>
	      <p>
		To get the best experience, please enable JavaScript or download a modern web browser such as <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet Explorer 8</a>, <a href="http://www.mozilla.com/en-US/firefox/firefox.html">Firefox</a>, <a href="http://www.apple.com/safari/download/">Safari</a>, or <a href="http://www.google.co.uk/chrome">Google Chrome</a>.
              </p>
	      </div>
	    </noscript>

	    <div id="recent_pages" class="hud_container">
	      <div id="recent_pages_header" class="hud_header">
		<div id="recent_pages_close" class="hud_close"><a href="#" onClick="recentPages.hide();return false;"></a></div>
		<div id="recent_pages_title" class="hud_title"><span class="hud_span_top">Recently read</span></div>
		<div id="recent_pages_topright" class="hud_topright"></div>
	      </div>
	      <div id="recent_pages_content" class="hud_content">
	      </div>
	      <div id="recent_pages_footer" class="hud_footer">
		<div id="recent_pages_bottomleft" class="hud_bottomleft"></div>
		<div id="recent_pages_bottom" class="hud_bottom"><span class="hud_span_bottom"></span></div>
		<div id="recent_pages_resize" class="hud_resize"></div>
	      </div>
	    </div>
  
	    <div id="from_search"></div>
            <h1>perlrebackslash</h1>


  <!--    -->
<ul><li><a href="#NAME">NAME</a><li><a href="#DESCRIPTION">DESCRIPTION</a><ul><li><a href="#The-backslash">The backslash</a><li><a href="#All-the-sequences-and-escapes">All the sequences and escapes</a><li><a href="#Character-Escapes">Character Escapes</a><li><a href="#Modifiers">Modifiers</a><li><a href="#Character-classes">Character classes</a><li><a href="#Referencing">Referencing</a><li><a href="#Assertions">Assertions</a><li><a href="#Misc">Misc</a></ul></ul><a name="NAME"></a><h1>NAME</h1>
<p>perlrebackslash - Perl Regular Expression Backslash Sequences and Escapes</p>
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
<p>The top level documentation about Perl regular expressions
is found in <a href="perlre.html">perlre</a>.</p>
<p>This document describes all backslash and escape sequences. After
explaining the role of the backslash, it lists all the sequences that have
a special meaning in Perl regular expressions (in alphabetical order),
then describes each of them.</p>
<p>Most sequences are described in detail in different documents; the primary
purpose of this document is to have a quick reference guide describing all
backslash and escape sequences.</p>
<a name="The-backslash"></a><h2>The backslash</h2>
<p>In a regular expression, the backslash can perform one of two tasks:
it either takes away the special meaning of the character following it
(for instance, <code class="inline">\|</code> matches a vertical bar, it's not an alternation),
or it is the start of a backslash or escape sequence.</p>
<p>The rules determining what it is are quite simple: if the character
following the backslash is an ASCII punctuation (non-word) character (that is,
anything that is not a letter, digit, or underscore), then the backslash just
takes away any special meaning of the character following it.</p>
<p>If the character following the backslash is an ASCII letter or an ASCII digit,
then the sequence may be special; if so, it's listed below. A few letters have
not been used yet, so escaping them with a backslash doesn't change them to be
special.  A future version of Perl may assign a special meaning to them, so if
you have warnings turned on, Perl issues a warning if you use such a
sequence.  [1].</p>
<p>It is however guaranteed that backslash or escape sequences never have a
punctuation character following the backslash, not now, and not in a future
version of Perl 5. So it is safe to put a backslash in front of a non-word
character.</p>
<p>Note that the backslash itself is special; if you want to match a backslash,
you have to escape the backslash with a backslash: <code class="inline"><span class="q">/\\/</span></code>
 matches a single
backslash.</p>
<ul>
<li><a name="%5b1%5d"></a><b>[1]</b>
<p>There is one exception. If you use an alphanumeric character as the
delimiter of your pattern (which you probably shouldn't do for readability
reasons), you have to escape the delimiter if you want to match
it. Perl won't warn then. See also <a href="perlop.html#Gory-details-of-parsing-quoted-constructs">Gory details of parsing quoted constructs in perlop</a>.</p>
</li>
</ul>
<a name="All-the-sequences-and-escapes"></a><h2>All the sequences and escapes</h2>
<p>Those not usable within a bracketed character class (like <code class="inline"><span class="s">[</span>\<span class="w">da</span>-z<span class="s">]</span></code>
) are marked
as <code class="inline"><span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</code>
</p>
<pre class="verbatim"><ol><li> \<span class="n">000</span>              <span class="w">Octal</span> <span class="w">escape</span> <span class="w">sequence</span>.  <span class="w">See</span> <span class="w">also</span> \<span class="w">o</span><span class="s">{</span><span class="s">}</span>.</li><li> \<span class="n">1</span>                <span class="w">Absolute</span> <span class="w">backreference</span>.  <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li><li> \<span class="w">a</span>                <span class="w">Alarm</span> <a class="l_k" href="functions/or.html">or</a> <span class="w">bell</span>.</li><li> \<span class="w">A</span>                <span class="w">Beginning</span> <span class="w">of</span> <span class="w">string</span>.  <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li><li> \<span class="w">b</span><span class="s">{</span><span class="s">}</span><span class="cm">,</span> \<span class="w">b</span>          <span class="w">Boundary</span>. <span class="s">(</span>\<span class="w">b</span> <span class="w">is</span> <span class="w">a</span> <span class="w">backspace</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span><span class="s">)</span>.</li><li> \<span class="w">B</span><span class="s">{</span><span class="s">}</span><span class="cm">,</span> \<span class="w">B</span>          <span class="w">Not</span> <span class="w">a</span> <span class="w">boundary</span>.  <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li><li> \<span class="w">cX</span>               <span class="w">Control</span><a class="l_k" href="functions/-X.html">-X</a>.</li><li> \<span class="w">d</span>                <span class="w">Match</span> <span class="w">any</span> <span class="w">digit</span> <span class="w">character</span>.</li><li> \<span class="w">D</span>                <span class="w">Match</span> <span class="w">any</span> <span class="w">character</span> <span class="w">that</span> <span class="w">isn&#39;t</span> <span class="w">a</span> <span class="w">digit</span>.</li><li> \<span class="w">e</span>                <span class="w">Escape</span> <span class="w">character</span>.</li><li> \<span class="w">E</span>                <span class="w">Turn</span> <span class="w">off</span> \<span class="w">Q</span><span class="cm">,</span> \<span class="w">L</span> <a class="l_k" href="functions/and.html">and</a> \<span class="w">U</span> <span class="w">processing</span>.  <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li><li> \<span class="w">f</span>                <span class="w">Form</span> <span class="w">feed</span>.</li><li> \<span class="w">F</span>                <span class="w">Foldcase</span> <span class="w">till</span> \<span class="w">E</span>.  <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li><li> \<span class="w">g</span><span class="s">{</span><span class="s">}</span><span class="cm">,</span> \<span class="w">g1</span>         <span class="w">Named</span><span class="cm">,</span> <span class="w">absolute</span> <a class="l_k" href="functions/or.html">or</a> <span class="w">relative</span> <span class="w">backreference</span>.</li><li>                   <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li><li> \<span class="w">G</span>                <span class="w">Pos</span> <span class="w">assertion</span>.  <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li><li> \<span class="w">h</span>                <span class="w">Match</span> <span class="w">any</span> <span class="w">horizontal</span> <span class="w">whitespace</span> <span class="w">character</span>.</li><li> \<span class="w">H</span>                <span class="w">Match</span> <span class="w">any</span> <span class="w">character</span> <span class="w">that</span> <span class="w">isn&#39;t</span> <span class="w">horizontal</span> <span class="w">whitespace</span>.</li><li> \<span class="w">k</span><span class="s">{</span><span class="s">}</span><span class="cm">,</span> \<span class="w">k</span>&lt;&gt;<span class="cm">,</span> \<span class="w">k&#39;</span><span class="q">&#39;  Named backreference.  Not in [].</span></li><li> <span class="q"> \K                Keep the stuff left of \K.  Not in [].</span></li><li> <span class="q"> \l                Lowercase next character.  Not in [].</span></li><li> <span class="q"> \L                Lowercase till \E.  Not in [].</span></li><li> <span class="q"> \n                (Logical) newline character.</span></li><li> <span class="q"> \N                Match any character but newline.  Not in [].</span></li><li> <span class="q"> \N{}              Named or numbered (Unicode) character or sequence.</span></li><li> <span class="q"> \o{}              Octal escape sequence.</span></li><li> <span class="q"> \p{}, \pP         Match any character with the given Unicode property.</span></li><li> <span class="q"> \P{}, \PP         Match any character without the given property.</span></li><li> <span class="q"> \Q                Quote (disable) pattern metacharacters till \E.  Not</span></li><li>                   <span class="q">                   in [].</span></li><li> <span class="q"> \r                Return character.</span></li><li> <span class="q"> \R                Generic new line.  Not in [].</span></li><li> <span class="q"> \s                Match any whitespace character.</span></li><li> <span class="q"> \S                Match any character that isn&#39;</span><span class="w">t</span> <span class="w">a</span> <span class="w">whitespace</span>.</li><li> \<span class="w">t</span>                <span class="w">Tab</span> <span class="w">character</span>.</li><li> \<span class="w">u</span>                <span class="w">Titlecase</span> <a class="l_k" href="functions/next.html">next</a> <span class="j">character</span>.  <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li><li> \<span class="w">U</span>                <span class="w">Uppercase</span> <span class="w">till</span> \<span class="w">E</span>.  <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li><li> \<span class="w">v</span>                <span class="w">Match</span> <span class="w">any</span> <span class="w">vertical</span> <span class="w">whitespace</span> <span class="w">character</span>.</li><li> \<span class="w">V</span>                <span class="w">Match</span> <span class="w">any</span> <span class="w">character</span> <span class="w">that</span> <span class="w">isn&#39;t</span> <span class="w">vertical</span> <span class="w">whitespace</span></li><li> \<span class="w">w</span>                <span class="w">Match</span> <span class="w">any</span> <span class="w">word</span> <span class="w">character</span>.</li><li> \<span class="w">W</span>                <span class="w">Match</span> <span class="w">any</span> <span class="w">character</span> <span class="w">that</span> <span class="w">isn&#39;t</span> <span class="w">a</span> <span class="w">word</span> <span class="w">character</span>.</li><li> \<span class="w">x</span><span class="s">{</span><span class="s">}</span><span class="cm">,</span> \<span class="w">x00</span>        <span class="w">Hexadecimal</span> <span class="w">escape</span> <span class="w">sequence</span>.</li><li> \<span class="w">X</span>                <span class="w">Unicode</span> <span class="q">&quot;extended grapheme cluster&quot;</span>.  <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li><li> \<span class="w">z</span>                <span class="w">End</span> <span class="w">of</span> <span class="w">string</span>.  <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li><li> \<span class="w">Z</span>                <span class="w">End</span> <span class="w">of</span> <span class="w">string</span>.  <span class="w">Not</span> <span class="w">in</span> <span class="s">[</span><span class="s">]</span>.</li></ol></pre><a name="Character-Escapes"></a><h2>Character Escapes</h2>
<a name="Fixed-characters"></a><h3>Fixed characters</h3>
<p>A handful of characters have a dedicated <i>character escape</i>. The following
table shows them, along with their ASCII code points (in decimal and hex),
their ASCII name, the control escape on ASCII platforms and a short
description.  (For EBCDIC platforms, see <a href="perlebcdic.html#OPERATOR-DIFFERENCES">OPERATOR DIFFERENCES in perlebcdic</a>.)</p>
<pre class="verbatim"><ol><li> <span class="w">Seq</span>.  <span class="w">Code</span> <span class="w">Point</span>  <span class="w">ASCII</span>   <span class="w">Cntrl</span>   <span class="w">Description</span>.</li><li>       <span class="w">Dec</span>    <span class="w">Hex</span></li><li>  \<span class="w">a</span>     <span class="n">7</span>     <span class="n">07</span>    <span class="w">BEL</span>    \<span class="w">cG</span>    <a class="l_k" href="functions/alarm.html">alarm</a> or <span class="w">bell</span></li><li>  \<span class="w">b</span>     <span class="n">8</span>     <span class="n">08</span>     <span class="w">BS</span>    \<span class="w">cH</span>    <span class="w">backspace</span> <span class="s">[</span><span class="n">1</span><span class="s">]</span></li><li>  \<span class="w">e</span>    <span class="n">27</span>     <span class="n">1</span><span class="w">B</span>    <span class="w">ESC</span>    \<span class="w">c</span><span class="s">[</span>    <span class="w">escape</span> <span class="w">character</span></li><li>  \<span class="w">f</span>    <span class="n">12</span>     <span class="n">0</span><span class="w">C</span>     <span class="w">FF</span>    \<span class="w">cL</span>    <span class="w">form</span> <span class="w">feed</span></li><li>  \<span class="w">n</span>    <span class="n">10</span>     <span class="n">0</span><span class="w">A</span>     <span class="w">LF</span>    \<span class="w">cJ</span>    <span class="w">line</span> <span class="w">feed</span> <span class="s">[</span><span class="n">2</span><span class="s">]</span></li><li>  \<span class="w">r</span>    <span class="n">13</span>     <span class="n">0</span><span class="w">D</span>     <span class="w">CR</span>    \<span class="w">cM</span>    <span class="w">carriage</span> <a class="l_k" href="functions/return.html">return</a></li><li>  \<span class="w">t</span>     <span class="n">9</span>     <span class="n">09</span>    <span class="w">TAB</span>    \<span class="w">cI</span>    <span class="w">tab</span></li></ol></pre><ul>
<li><a name="%5b1%5d"></a><b>[1]</b>
<p><code class="inline">\<span class="w">b</span></code>
 is the backspace character only inside a character class. Outside a
character class, <code class="inline">\<span class="w">b</span></code>
 alone is a word-character/non-word-character
boundary, and <code class="inline">\<span class="w">b</span><span class="s">{</span><span class="s">}</span></code>
 is some other type of boundary.</p>
</li>
<li><a name="%5b2%5d"></a><b>[2]</b>
<p><code class="inline">\<span class="w">n</span></code>
 matches a logical newline. Perl converts between <code class="inline">\<span class="w">n</span></code>
 and your
OS's native newline character when reading from or writing to text files.</p>
</li>
</ul>
<h4>Example</h4>
<pre class="verbatim"><ol><li> <span class="i">$str</span> =~ <span class="q">/\t/</span><span class="sc">;</span>   <span class="c"># Matches if $str contains a (horizontal) tab.</span></li></ol></pre><a name="Control-characters"></a><h3>Control characters</h3>
<p><code class="inline">\<span class="w">c</span></code>
 is used to denote a control character; the character following <code class="inline">\<span class="w">c</span></code>

determines the value of the construct.  For example the value of <code class="inline">\<span class="w">cA</span></code>
 is
<code class="inline"><a class="l_k" href="functions/chr.html">chr(1)</a></code>, and the value of <code class="inline">\<span class="w">cb</span></code>
 is <code class="inline"><a class="l_k" href="functions/chr.html">chr(2)</a></code>, etc.
The gory details are in <a href="perlop.html#Regexp-Quote-Like-Operators">Regexp Quote-Like Operators in perlop</a>.  A complete
list of what <code class="inline"><a class="l_k" href="functions/chr.html">chr(1)</a></code>, etc. means for ASCII and EBCDIC platforms is in
<a href="perlebcdic.html#OPERATOR-DIFFERENCES">OPERATOR DIFFERENCES in perlebcdic</a>.</p>
<p>Note that <code class="inline">\<span class="w">c</span>\</code>
 alone at the end of a regular expression (or doubled-quoted
string) is not valid.  The backslash must be followed by another character.
That is, <code class="inline">\c\<i>X</i></code> means <code class="inline">chr(28) . '<i>X</i>'</code> for all characters <i>X</i>.</p>
<p>To write platform-independent code, you must use <code class="inline">\N{<i>NAME</i>}</code> instead, like
<code class="inline">\<span class="i">N</span><span class="s">{</span><span class="w">ESCAPE</span><span class="s">}</span></code>
 or <code class="inline">\<span class="i">N</span><span class="s">{</span><span class="w">U</span>+<span class="n">001</span><span class="w">B</span><span class="s">}</span></code>
, see <a href="charnames.html">charnames</a>.</p>
<p>Mnemonic: <i>c</i>ontrol character.</p>
<h4>Example</h4>
<pre class="verbatim"><ol><li> <span class="i">$str</span> =~ <span class="q">/\cK/</span><span class="sc">;</span>  <span class="c"># Matches if $str contains a vertical tab (control-K).</span></li></ol></pre><a name="Named-or-numbered-characters-and-character-sequences"></a><h3>Named or numbered characters and character sequences</h3>
<p>Unicode characters have a Unicode name and numeric code point (ordinal)
value.  Use the
<code class="inline">\<span class="w">N</span><span class="s">{</span><span class="s">}</span></code>
 construct to specify a character by either of these values.
Certain sequences of characters also have names.</p>
<p>To specify by name, the name of the character or character sequence goes
between the curly braces.</p>
<p>To specify a character by Unicode code point, use the form <code class="inline">\N{U+<i>code
point</i>}</code>, where <i>code point</i> is a number in hexadecimal that gives the
code point that Unicode has assigned to the desired character.  It is
customary but not required to use leading zeros to pad the number to 4
digits.  Thus <code class="inline">\<span class="i">N</span><span class="s">{</span><span class="w">U</span>+<span class="n">0041</span><span class="s">}</span></code>
 means <code class="inline"><span class="w">LATIN</span> <span class="w">CAPITAL</span> <span class="w">LETTER</span> <span class="w">A</span></code>
, and you will
rarely see it written without the two leading zeros.  <code class="inline">\<span class="i">N</span><span class="s">{</span><span class="w">U</span>+<span class="n">0041</span><span class="s">}</span></code>
 means
"A" even on EBCDIC machines (where the ordinal value of "A" is not 0x41).</p>
<p>It is even possible to give your own names to characters and character
sequences.  For details, see <a href="charnames.html">charnames</a>.</p>
<p>(There is an expanded internal form that you may see in debug output:
<code class="inline">\N{U+<i>code point</i>.<i>code point</i>...}</code>.
The <code class="inline">...</code>
 means any number of these <i>code point</i>s separated by dots.
This represents the sequence formed by the characters.  This is an internal
form only, subject to change, and you should not try to use it yourself.)</p>
<p>Mnemonic: <i>N</i>amed character.</p>
<p>Note that a character or character sequence expressed as a named
or numbered character is considered a character without special
meaning by the regex engine, and will match "as is".</p>
<h4>Example</h4>
<pre class="verbatim"><ol><li> <span class="i">$str</span> =~ <span class="q">/\N{THAI CHARACTER SO SO}/</span><span class="sc">;</span>  <span class="c"># Matches the Thai SO SO character</span></li><li></li><li> <a class="l_k" href="functions/use.html">use</a> <span class="w">charnames</span> <span class="q">&#39;Cyrillic&#39;</span><span class="sc">;</span>            <span class="c"># Loads Cyrillic names.</span></li><li> <span class="i">$str</span> =~ <span class="q">/\N{ZHE}\N{KA}/</span><span class="sc">;</span>             <span class="c"># Match &quot;ZHE&quot; followed by &quot;KA&quot;.</span></li></ol></pre><a name="Octal-escapes"></a><h3>Octal escapes</h3>
<p>There are two forms of octal escapes.  Each is used to specify a character by
its code point specified in octal notation.</p>
<p>One form, available starting in Perl 5.14 looks like <code class="inline">\<span class="i">o</span><span class="s">{</span>...<span class="s">}</span></code>
, where the dots
represent one or more octal digits.  It can be used for any Unicode character.</p>
<p>It was introduced to avoid the potential problems with the other form,
available in all Perls.  That form consists of a backslash followed by three
octal digits.  One problem with this form is that it can look exactly like an
old-style backreference (see
<a href="#Disambiguation-rules-between-old-style-octal-escapes-and-backreferences">Disambiguation rules between old-style octal escapes and backreferences</a>
below.)  You can avoid this by making the first of the three digits always a
zero, but that makes \077 the largest code point specifiable.</p>
<p>In some contexts, a backslash followed by two or even one octal digits may be
interpreted as an octal escape, sometimes with a warning, and because of some
bugs, sometimes with surprising results.  Also, if you are creating a regex
out of smaller snippets concatenated together, and you use fewer than three
digits, the beginning of one snippet may be interpreted as adding digits to the
ending of the snippet before it.  See <a href="#Absolute-referencing">Absolute referencing</a> for more
discussion and examples of the snippet problem.</p>
<p>Note that a character expressed as an octal escape is considered
a character without special meaning by the regex engine, and will match
"as is".</p>
<p>To summarize, the <code class="inline">\<span class="w">o</span><span class="s">{</span><span class="s">}</span></code>
 form is always safe to use, and the other form is
safe to use for code points through \077 when you use exactly three digits to
specify them.</p>
<p>Mnemonic: <i>0</i>ctal or <i>o</i>ctal.</p>
<h4>Examples (assuming an ASCII platform)</h4>
<pre class="verbatim"><ol><li> <span class="i">$str</span> = <span class="q">&quot;Perl&quot;</span><span class="sc">;</span></li><li> <span class="i">$str</span> =~ <span class="q">/\o{120}/</span><span class="sc">;</span>  <span class="c"># Match, &quot;\120&quot; is &quot;P&quot;.</span></li><li> <span class="i">$str</span> =~ <span class="q">/\120/</span><span class="sc">;</span>     <span class="c"># Same.</span></li><li> <span class="i">$str</span> =~ <span class="q">/\o{120}+/</span><span class="sc">;</span> <span class="c"># Match, &quot;\120&quot; is &quot;P&quot;,</span></li><li>                     <span class="c"># it&#39;s repeated at least once.</span></li><li> <span class="i">$str</span> =~ <span class="q">/\120+/</span><span class="sc">;</span>    <span class="c"># Same.</span></li><li> <span class="i">$str</span> =~ <span class="q">/P\053/</span><span class="sc">;</span>    <span class="c"># No match, &quot;\053&quot; is &quot;+&quot; and taken literally.</span></li><li> <span class="q">/\o{23073}/</span>         <span class="c"># Black foreground, white background smiling face.</span></li><li> /\<span class="i">o</span><span class="s">{</span><span class="n">4801234567</span><span class="s">}</span><span class="q">/    # Raises a warning, and yields chr(4).</span></li></ol></pre><h4>Disambiguation rules between old-style octal escapes and backreferences</h4>
<p>Octal escapes of the <code class="inline">\<span class="n">000</span></code>
 form outside of bracketed character classes
potentially clash with old-style backreferences (see <a href="#Absolute-referencing">Absolute referencing</a>
below).  They both consist of a backslash followed by numbers.  So Perl has to
use heuristics to determine whether it is a backreference or an octal escape.
Perl uses the following rules to disambiguate:</p>
<dl>
<dt>1</dt><dd>
<p>If the backslash is followed by a single digit, it's a backreference.</p>
</dd>
<dt>2</dt><dd>
<p>If the first digit following the backslash is a 0, it's an octal escape.</p>
</dd>
<dt>3</dt><dd>
<p>If the number following the backslash is N (in decimal), and Perl already
has seen N capture groups, Perl considers this a backreference.  Otherwise,
it considers it an octal escape. If N has more than three digits, Perl
takes only the first three for the octal escape; the rest are matched as is.</p>
<pre class="verbatim"><ol><li> <a class="l_k" href="functions/my.html">my</a> <span class="i">$pat</span>  = <span class="q">&quot;(&quot;</span> x <span class="n">999</span><span class="sc">;</span></li><li>    <span class="i">$pat</span> .= <span class="q">&quot;a&quot;</span><span class="sc">;</span></li><li>    <span class="i">$pat</span> .= <span class="q">&quot;)&quot;</span> x <span class="n">999</span><span class="sc">;</span></li><li> <span class="q">/^($pat)\1000$/</span><span class="sc">;</span>   <span class="c">#  Matches &#39;aa&#39;; there are 1000 capture groups.</span></li><li> <span class="q">/^$pat\1000$/</span><span class="sc">;</span>     <span class="c">#  Matches &#39;a@0&#39;; there are 999 capture groups</span></li><li>                    <span class="c">#  and \1000 is seen as \100 (a &#39;@&#39;) and a &#39;0&#39;.</span></li></ol></pre></dd>
</dl>
<p>You can force a backreference interpretation always by using the <code class="inline">\<span class="i">g</span><span class="s">{</span>...<span class="s">}</span></code>

form.  You can the force an octal interpretation always by using the <code class="inline">\<span class="i">o</span><span class="s">{</span>...<span class="s">}</span></code>

form, or for numbers up through \077 (= 63 decimal), by using three digits,
beginning with a "0".</p>
<a name="Hexadecimal-escapes"></a><h3>Hexadecimal escapes</h3>
<p>Like octal escapes, there are two forms of hexadecimal escapes, but both start
with the sequence <code class="inline">\<span class="w">x</span></code>
.  This is followed by either exactly two hexadecimal
digits forming a number, or a hexadecimal number of arbitrary length surrounded
by curly braces. The hexadecimal number is the code point of the character you
want to express.</p>
<p>Note that a character expressed as one of these escapes is considered a
character without special meaning by the regex engine, and will match
"as is".</p>
<p>Mnemonic: he<i>x</i>adecimal.</p>
<h4>Examples (assuming an ASCII platform)</h4>
<pre class="verbatim"><ol><li> <span class="i">$str</span> = <span class="q">&quot;Perl&quot;</span><span class="sc">;</span></li><li> <span class="i">$str</span> =~ <span class="q">/\x50/</span><span class="sc">;</span>    <span class="c"># Match, &quot;\x50&quot; is &quot;P&quot;.</span></li><li> <span class="i">$str</span> =~ <span class="q">/\x50+/</span><span class="sc">;</span>   <span class="c"># Match, &quot;\x50&quot; is &quot;P&quot;, it is repeated at least once</span></li><li> <span class="i">$str</span> =~ <span class="q">/P\x2B/</span><span class="sc">;</span>   <span class="c"># No match, &quot;\x2B&quot; is &quot;+&quot; and taken literally.</span></li><li></li><li> <span class="q">/\x{2603}\x{2602}/</span> <span class="c"># Snowman with an umbrella.</span></li><li>                    <span class="c"># The Unicode character 2603 is a snowman,</span></li><li>                    <span class="c"># the Unicode character 2602 is an umbrella.</span></li><li> /\<span class="i">x</span><span class="s">{</span><span class="n">263</span><span class="w">B</span><span class="s">}</span><span class="q">/         # Black smiling face.</span></li><li> <span class="q"> /</span>\<span class="i">x</span><span class="s">{</span><span class="n">263</span><span class="w">b</span><span class="s">}</span><span class="q">/         # Same, the hex digits A - F are case insensitive.</span></li></ol></pre><a name="Modifiers"></a><h2>Modifiers</h2>
<p>A number of backslash sequences have to do with changing the character,
or characters following them. <code class="inline">\<span class="w">l</span></code>
 will lowercase the character following
it, while <code class="inline">\<span class="w">u</span></code>
 will uppercase (or, more accurately, titlecase) the
character following it. They provide functionality similar to the
functions <code class="inline"><a class="l_k" href="functions/lcfirst.html">lcfirst</a></code> and <code class="inline"><a class="l_k" href="functions/ucfirst.html">ucfirst</a></code>.</p>
<p>To uppercase or lowercase several characters, one might want to use
<code class="inline">\<span class="w">L</span></code>
 or <code class="inline">\<span class="w">U</span></code>
, which will lowercase/uppercase all characters following
them, until either the end of the pattern or the next occurrence of
<code class="inline">\<span class="w">E</span></code>
, whichever comes first. They provide functionality similar to what
the functions <code class="inline"><a class="l_k" href="functions/lc.html">lc</a></code> and <code class="inline"><a class="l_k" href="functions/uc.html">uc</a></code> provide.</p>
<p><code class="inline">\<span class="w">Q</span></code>
 is used to quote (disable) pattern metacharacters, up to the next
<code class="inline">\<span class="w">E</span></code>
 or the end of the pattern. <code class="inline">\<span class="w">Q</span></code>
 adds a backslash to any character
that could have special meaning to Perl.  In the ASCII range, it quotes
every character that isn't a letter, digit, or underscore.  See
<a href="functions/quotemeta.html">quotemeta</a> for details on what gets quoted for non-ASCII
code points.  Using this ensures that any character between <code class="inline">\<span class="w">Q</span></code>
 and
<code class="inline">\<span class="w">E</span></code>
 will be matched literally, not interpreted as a metacharacter by
the regex engine.</p>
<p><code class="inline">\<span class="w">F</span></code>
 can be used to casefold all characters following, up to the next <code class="inline">\<span class="w">E</span></code>

or the end of the pattern. It provides the functionality similar to
the <code class="inline"><a class="l_k" href="functions/fc.html">fc</a></code> function.</p>
<p>Mnemonic: <i>L</i>owercase, <i>U</i>ppercase, <i>F</i>old-case, <i>Q</i>uotemeta, <i>E</i>nd.</p>
<h4>Examples</h4>
<pre class="verbatim"><ol><li> <span class="i">$sid</span>     = <span class="q">&quot;sid&quot;</span><span class="sc">;</span></li><li> <span class="i">$greg</span>    = <span class="q">&quot;GrEg&quot;</span><span class="sc">;</span></li><li> <span class="i">$miranda</span> = <span class="q">&quot;(Miranda)&quot;</span><span class="sc">;</span></li><li> <span class="i">$str</span>     =~ <span class="q">/\u$sid/</span><span class="sc">;</span>        <span class="c"># Matches &#39;Sid&#39;</span></li><li> <span class="i">$str</span>     =~ <span class="q">/\L$greg/</span><span class="sc">;</span>       <span class="c"># Matches &#39;greg&#39;</span></li><li> <span class="i">$str</span>     =~ <span class="q">/\Q$miranda\E/</span><span class="sc">;</span>  <span class="c"># Matches &#39;(Miranda)&#39;, as if the pattern</span></li><li>                              <span class="c">#   had been written as /\(Miranda\)/</span></li></ol></pre><a name="Character-classes"></a><h2>Character classes</h2>
<p>Perl regular expressions have a large range of character classes. Some of
the character classes are written as a backslash sequence. We will briefly
discuss those here; full details of character classes can be found in
<a href="perlrecharclass.html">perlrecharclass</a>.</p>
<p><code class="inline">\<span class="w">w</span></code>
 is a character class that matches any single <i>word</i> character
(letters, digits, Unicode marks, and connector punctuation (like the
underscore)).  <code class="inline">\<span class="w">d</span></code>
 is a character class that matches any decimal
digit, while the character class <code class="inline">\s</code> matches any whitespace character.
New in perl 5.10.0 are the classes <code class="inline">\<span class="w">h</span></code>
 and <code class="inline">\<span class="w">v</span></code>
 which match horizontal
and vertical whitespace characters.</p>
<p>The exact set of characters matched by <code class="inline">\<span class="w">d</span></code>
, <code class="inline">\s</code>, and <code class="inline">\<span class="w">w</span></code>
 varies
depending on various pragma and regular expression modifiers.  It is
possible to restrict the match to the ASCII range by using the <code class="inline"><span class="q">/a</span></code>

regular expression modifier.  See <a href="perlrecharclass.html">perlrecharclass</a>.</p>
<p>The uppercase variants (<code class="inline">\<span class="w">W</span></code>
, <code class="inline">\<span class="w">D</span></code>
, <code class="inline">\<span class="w">S</span></code>
, <code class="inline">\<span class="w">H</span></code>
, and <code class="inline">\<span class="w">V</span></code>
) are
character classes that match, respectively, any character that isn't a
word character, digit, whitespace, horizontal whitespace, or vertical
whitespace.</p>
<p>Mnemonics: <i>w</i>ord, <i>d</i>igit, <i>s</i>pace, <i>h</i>orizontal, <i>v</i>ertical.</p>
<a name="Unicode-classes"></a><h3>Unicode classes</h3>
<p><code class="inline">\<span class="w">pP</span></code>
 (where <code class="inline"><span class="w">P</span></code>
 is a single letter) and <code class="inline">\<span class="i">p</span><span class="s">{</span><span class="w">Property</span><span class="s">}</span></code>
 are used to
match a character that matches the given Unicode property; properties
include things like "letter", or "thai character". Capitalizing the
sequence to <code class="inline">\<span class="w">PP</span></code>
 and <code class="inline">\<span class="i">P</span><span class="s">{</span><span class="w">Property</span><span class="s">}</span></code>
 make the sequence match a character
that doesn't match the given Unicode property. For more details, see
<a href="perlrecharclass.html#Backslash-sequences">Backslash sequences in perlrecharclass</a> and
<a href="perlunicode.html#Unicode-Character-Properties">Unicode Character Properties in perlunicode</a>.</p>
<p>Mnemonic: <i>p</i>roperty.</p>
<a name="Referencing"></a><h2>Referencing</h2>
<p>If capturing parenthesis are used in a regular expression, we can refer
to the part of the source string that was matched, and match exactly the
same thing. There are three ways of referring to such <i>backreference</i>:
absolutely, relatively, and by name.</p>
<a name="Absolute-referencing"></a><h3>Absolute referencing</h3>
<p>Either <code class="inline">\g<i>N</i></code> (starting in Perl 5.10.0), or <code class="inline">\<i>N</i></code> (old-style) where <i>N</i>
is a positive (unsigned) decimal number of any length is an absolute reference
to a capturing group.</p>
<p><i>N</i> refers to the Nth set of parentheses, so <code class="inline">\g<i>N</i></code> refers to whatever has
been matched by that set of parentheses.  Thus <code class="inline">\<span class="w">g1</span></code>
 refers to the first
capture group in the regex.</p>
<p>The <code class="inline">\g<i>N</i></code> form can be equivalently written as <code class="inline">\g{<i>N</i>}</code>
which avoids ambiguity when building a regex by concatenating shorter
strings.  Otherwise if you had a regex <code class="inline"><a class="l_k" href="functions/qr.html">qr/$a$b/</a></code>, and <code class="inline"><span class="i">$a</span></code>
 contained
<code class="inline"><span class="q">&quot;\g1&quot;</span></code>
, and <code class="inline"><span class="i">$b</span></code>
 contained <code class="inline"><span class="q">&quot;37&quot;</span></code>
, you would get <code class="inline"><span class="q">/\g137/</span></code>
 which is
probably not what you intended.</p>
<p>In the <code class="inline">\<i>N</i></code> form, <i>N</i> must not begin with a "0", and there must be at
least <i>N</i> capturing groups, or else <i>N</i> is considered an octal escape
(but something like <code class="inline">\<span class="n">18</span></code>
 is the same as <code class="inline">\<span class="n">0018</span></code>
; that is, the octal escape
<code class="inline"><span class="q">&quot;\001&quot;</span></code>
 followed by a literal digit <code class="inline"><span class="q">&quot;8&quot;</span></code>
).</p>
<p>Mnemonic: <i>g</i>roup.</p>
<h4>Examples</h4>
<pre class="verbatim"><ol><li> <span class="q">/(\w+) \g1/</span><span class="sc">;</span>    <span class="c"># Finds a duplicated word, (e.g. &quot;cat cat&quot;).</span></li><li> <span class="q">/(\w+) \1/</span><span class="sc">;</span>     <span class="c"># Same thing; written old-style.</span></li><li> <span class="q">/(.)(.)\g2\g1/</span><span class="sc">;</span>  <span class="c"># Match a four letter palindrome (e.g. &quot;ABBA&quot;).</span></li></ol></pre><a name="Relative-referencing"></a><h3>Relative referencing</h3>
<p><code class="inline">\g-<i>N</i></code> (starting in Perl 5.10.0) is used for relative addressing.  (It can
be written as <code class="inline">\g{-<i>N</i></code>.)  It refers to the <i>N</i>th group before the
<code class="inline">\g{-<i>N</i>}</code>.</p>
<p>The big advantage of this form is that it makes it much easier to write
patterns with references that can be interpolated in larger patterns,
even if the larger pattern also contains capture groups.</p>
<h4>Examples</h4>
<pre class="verbatim"><ol><li> <span class="q">/(A)        # Group 1</span></li><li>  <span class="q">  (          # Group 2</span></li><li>    <span class="q">    (B)      # Group 3</span></li><li>    <span class="q">    \g{-1}   # Refers to group 3 (B)</span></li><li>    <span class="q">    \g{-3}   # Refers to group 1 (A)</span></li><li>  <span class="q">  )</span></li><li> <span class="q"> /x</span><span class="sc">;</span>         <span class="c"># Matches &quot;ABBA&quot;.</span></li><li></li><li> <a class="l_k" href="functions/my.html">my</a> <span class="i">$qr</span> = <span class="q">qr /(.)(.)\g{-2}\g{-1}/</span><span class="sc">;</span>  <span class="c"># Matches &#39;abab&#39;, &#39;cdcd&#39;, etc.</span></li><li> <span class="q">/$qr$qr/</span>                           <span class="c"># Matches &#39;ababcdcd&#39;.</span></li></ol></pre><a name="Named-referencing"></a><h3>Named referencing</h3>
<p><code class="inline">\g{<i>name</i>}</code> (starting in Perl 5.10.0) can be used to back refer to a
named capture group, dispensing completely with having to think about capture
buffer positions.</p>
<p>To be compatible with .Net regular expressions, <code class="inline">\<span class="i">g</span><span class="s">{</span><span class="w">name</span><span class="s">}</span></code>
 may also be
written as <code class="inline">\<span class="i">k</span><span class="s">{</span><span class="w">name</span><span class="s">}</span></code>
, <code class="inline">\<span class="w">k</span><span class="q">&lt;name&gt;</span></code>
 or <code class="inline">\k'name'</code>.</p>
<p>To prevent any ambiguity, <i>name</i> must not start with a digit nor contain a
hyphen.</p>
<h4>Examples</h4>
<pre class="verbatim"><ol><li> <span class="q">/(?&lt;word&gt;\w+) \g{word}/</span> <span class="c"># Finds duplicated word, (e.g. &quot;cat cat&quot;)</span></li><li> /<span class="s">(</span><span class="q">?&lt;word&gt;\w+) \k{word}/ # Same.</span></li><li> <span class="q"> /(?</span>&lt;<span class="w">word</span>&gt;\<span class="w">w</span>+<span class="s">)</span> \<span class="w">k</span><span class="q">&lt;word&gt;</span>/ <span class="c"># Same.</span></li><li> <span class="q">/(?&lt;letter1&gt;.)(?&lt;letter2&gt;.)\g{letter2}\g{letter1}/</span></li><li>                         <span class="c"># Match a four letter palindrome (e.g. &quot;ABBA&quot;)</span></li></ol></pre><a name="Assertions"></a><h2>Assertions</h2>
<p>Assertions are conditions that have to be true; they don't actually
match parts of the substring. There are six assertions that are written as
backslash sequences.</p>
<ul>
<li><a name="%5cA"></a><b>\A</b>
<p><code class="inline">\<span class="w">A</span></code>
 only matches at the beginning of the string. If the <code class="inline">/m</code> modifier
isn't used, then <code class="inline"><span class="q">/\A/</span></code>
 is equivalent to <code class="inline"><span class="q">/^/</span></code>
. However, if the <code class="inline">/m</code>
modifier is used, then <code class="inline"><span class="q">/^/</span></code>
 matches internal newlines, but the meaning
of <code class="inline"><span class="q">/\A/</span></code>
 isn't changed by the <code class="inline">/m</code> modifier. <code class="inline">\<span class="w">A</span></code>
 matches at the beginning
of the string regardless whether the <code class="inline">/m</code> modifier is used.</p>
</li>
<li><a name="%5cz%2c-%5cZ"></a><b>\z, \Z</b>
<p><code class="inline">\<span class="w">z</span></code>
 and <code class="inline">\<span class="w">Z</span></code>
 match at the end of the string. If the <code class="inline">/m</code> modifier isn't
used, then <code class="inline"><span class="q">/\Z/</span></code>
 is equivalent to <code class="inline"><span class="q">/$/</span></code>
; that is, it matches at the
end of the string, or one before the newline at the end of the string. If the
<code class="inline">/m</code> modifier is used, then <code class="inline"><span class="q">/$/</span></code>
 matches at internal newlines, but the
meaning of <code class="inline"><span class="q">/\Z/</span></code>
 isn't changed by the <code class="inline">/m</code> modifier. <code class="inline">\<span class="w">Z</span></code>
 matches at
the end of the string (or just before a trailing newline) regardless whether
the <code class="inline">/m</code> modifier is used.</p>
<p><code class="inline">\<span class="w">z</span></code>
 is just like <code class="inline">\<span class="w">Z</span></code>
, except that it does not match before a trailing
newline. <code class="inline">\<span class="w">z</span></code>
 matches at the end of the string only, regardless of the
modifiers used, and not just before a newline.  It is how to anchor the
match to the true end of the string under all conditions.</p>
</li>
<li><a name="%5cG"></a><b>\G</b>
<p><code class="inline">\<span class="w">G</span></code>
 is usually used only in combination with the <code class="inline">/g</code> modifier. If the
<code class="inline">/g</code> modifier is used and the match is done in scalar context, Perl 
remembers where in the source string the last match ended, and the next time,
it will start the match from where it ended the previous time.</p>
<p><code class="inline">\<span class="w">G</span></code>
 matches the point where the previous match on that string ended, 
or the beginning of that string if there was no previous match.</p>
<p>Mnemonic: <i>G</i>lobal.</p>
</li>
<li><a name="%5cb%7b%7d%2c-%5cb%2c-%5cB%7b%7d%2c-%5cB"></a><b>\b{}, \b, \B{}, \B</b>
<p><code class="inline">\<span class="i">b</span><span class="s">{</span>...<span class="s">}</span></code>
, available starting in v5.22, matches a boundary (between two
characters, or before the first character of the string, or after the
final character of the string) based on the Unicode rules for the
boundary type specified inside the braces.  The boundary
types are given a few paragraphs below.  <code class="inline">\<span class="i">B</span><span class="s">{</span>...<span class="s">}</span></code>
 matches at any place
between characters where <code class="inline">\<span class="i">b</span><span class="s">{</span>...<span class="s">}</span></code>
 of the same type doesn't match.</p>
<p><code class="inline">\<span class="w">b</span></code>
 when not immediately followed by a <code class="inline"><span class="q">&quot;{&quot;</span></code>
 matches at any place
between a word (something matched by <code class="inline">\<span class="w">w</span></code>
) and a non-word character
(<code class="inline">\<span class="w">W</span></code>
); <code class="inline">\<span class="w">B</span></code>
 when not immediately followed by a <code class="inline"><span class="q">&quot;{&quot;</span></code>
 matches at any
place between characters where <code class="inline">\<span class="w">b</span></code>
 doesn't match.  To get better
word matching of natural language text, see <a href="#%5cb%7bwb%7d">\b{wb}</a> below.</p>
<p><code class="inline">\<span class="w">b</span></code>

and <code class="inline">\<span class="w">B</span></code>
 assume there's a non-word character before the beginning and after
the end of the source string; so <code class="inline">\<span class="w">b</span></code>
 will match at the beginning (or end)
of the source string if the source string begins (or ends) with a word
character. Otherwise, <code class="inline">\<span class="w">B</span></code>
 will match.</p>
<p>Do not use something like <code class="inline">\<span class="w">b</span>=<span class="w">head</span>\<span class="w">d</span>\<span class="w">b</span></code>
 and expect it to match the
beginning of a line.  It can't, because for there to be a boundary before
the non-word "=", there must be a word character immediately previous.  
All plain <code class="inline">\<span class="w">b</span></code>
 and <code class="inline">\<span class="w">B</span></code>
 boundary determinations look for word
characters alone, not for
non-word characters nor for string ends.  It may help to understand how
<code class="inline">\<span class="w">b</span></code>
 and <code class="inline">\<span class="w">B</span></code>
 work by equating them as follows:</p>
<pre class="verbatim"><ol><li>    \<span class="w">b</span>	<span class="w">really</span> <span class="w">means</span>	<span class="s">(</span><span class="q">?:(?</span>&lt;=\<span class="w">w</span><span class="s">)</span><span class="s">(</span><span class="q">?!\w)|(?</span>&lt;!\<span class="w">w</span><span class="s">)</span><span class="s">(</span><span class="q">?=\w))</span></li><li>    <span class="q">    \B	really means	(?</span><span class="co">:</span><span class="s">(</span><span class="q">?&lt;=\w)(?</span>=\<span class="w">w</span><span class="s">)</span>|<span class="s">(</span><span class="q">?&lt;!\w)(?</span>!\<span class="w">w</span><span class="s">)</span><span class="s">)</span></li></ol></pre><p>In contrast, <code class="inline">\<span class="i">b</span><span class="s">{</span>...<span class="s">}</span></code>
 and <code class="inline">\<span class="i">B</span><span class="s">{</span>...<span class="s">}</span></code>
 may or may not match at the
beginning and end of the line, depending on the boundary type.  These
implement the Unicode default boundaries, specified in
<a href="http://www.unicode.org/reports/tr14/">http://www.unicode.org/reports/tr14/</a> and
<a href="http://www.unicode.org/reports/tr29/">http://www.unicode.org/reports/tr29/</a>.
The boundary types are:</p>
<ul>
<li><a name="%5cb%7bgcb%7d-or-%5cb%7bg%7d"></a><b><code class="inline">\<span class="i">b</span><span class="s">{</span><span class="w">gcb</span><span class="s">}</span></code>
 or <code class="inline">\<span class="i">b</span><span class="s">{</span><span class="w">g</span><span class="s">}</span></code>
</b>
<p>This matches a Unicode "Grapheme Cluster Boundary".  (Actually Perl
always uses the improved "extended" grapheme cluster").  These are
explained below under <a href="#%5cX">\X</a>.  In fact, <code class="inline">\<span class="w">X</span></code>
 is another way to get
the same functionality.  It is equivalent to <code class="inline"><span class="q">/.+?\b{gcb}/</span></code>
.  Use
whichever is most convenient for your situation.</p>
</li>
<li><a name="%5cb%7blb%7d"></a><b><code class="inline">\<span class="i">b</span><span class="s">{</span><span class="w">lb</span><span class="s">}</span></code>
</b>
<p>This matches according to the default Unicode Line Breaking Algorithm
(<a href="http://www.unicode.org/reports/tr14/">http://www.unicode.org/reports/tr14/</a>), as customized in that
document
(<a href="http://search.cpan.org/perldoc/http:#%2fwww.unicode.org%2freports%2ftr14%2ftr14-35.html%23Example7">Example 7 of revision 35</a>)
for better handling of numeric expressions.</p>
<p>This is suitable for many purposes, but the <a href="http://search.cpan.org/perldoc/Unicode::LineBreak">Unicode::LineBreak</a> module
is available on CPAN that provides many more features, including
customization.</p>
</li>
<li><a name="%5cb%7bsb%7d"></a><b><code class="inline">\<span class="i">b</span><span class="s">{</span><span class="w">sb</span><span class="s">}</span></code>
</b>
<p>This matches a Unicode "Sentence Boundary".  This is an aid to parsing
natural language sentences.  It gives good, but imperfect results.  For
example, it thinks that "Mr. Smith" is two sentences.  More details are
at <a href="http://www.unicode.org/reports/tr29/">http://www.unicode.org/reports/tr29/</a>.  Note also that it thinks
that anything matching <a href="#%5cR">\R</a> (except form feed and vertical tab) is a
sentence boundary.  <code class="inline">\<span class="i">b</span><span class="s">{</span><span class="w">sb</span><span class="s">}</span></code>
 works with text designed for
word-processors which wrap lines
automatically for display, but hard-coded line boundaries are considered
to be essentially the ends of text blocks (paragraphs really), and hence
the ends of sententces.  <code class="inline">\<span class="i">b</span><span class="s">{</span><span class="w">sb</span><span class="s">}</span></code>
 doesn't do well with text containing
embedded newlines, like the source text of the document you are reading.
Such text needs to be preprocessed to get rid of the line separators
before looking for sentence boundaries.  Some people view this as a bug
in the Unicode standard, and this behavior is quite subject to change in
future Perl versions.</p>
</li>
<li><a name="%5cb%7bwb%7d"></a><b><code class="inline">\<span class="i">b</span><span class="s">{</span><span class="w">wb</span><span class="s">}</span></code>
</b>
<p>This matches a Unicode "Word Boundary", but tailored to Perl
expectations.  This gives better (though not
perfect) results for natural language processing than plain <code class="inline">\<span class="w">b</span></code>

(without braces) does.  For example, it understands that apostrophes can
be in the middle of words and that parentheses aren't (see the examples
below).  More details are at <a href="http://www.unicode.org/reports/tr29/">http://www.unicode.org/reports/tr29/</a>.</p>
<p>The current Unicode definition of a Word Boundary matches between every
white space character.  Perl tailors this, starting in version 5.24, to
generally not break up spans of white space, just as plain <code class="inline">\<span class="w">b</span></code>
 has
always functioned.  This allows <code class="inline">\<span class="i">b</span><span class="s">{</span><span class="w">wb</span><span class="s">}</span></code>
 to be a drop-in replacement for
<code class="inline">\<span class="w">b</span></code>
, but with generally better results for natural language
processing.  (The exception to this tailoring is when a span of white
space is immediately followed by something like U+0303, COMBINING TILDE.
If the final space character in the span is a horizontal white space, it
is broken out so that it attaches instead to the combining character.
To be precise, if a span of white space that ends in a horizontal space
has the character immediately following it have either of the Word
Boundary property values "Extend", "Format" or "ZWJ", the boundary between the
final horizontal space character and the rest of the span matches
<code class="inline">\<span class="i">b</span><span class="s">{</span><span class="w">wb</span><span class="s">}</span></code>
.  In all other cases the boundary between two white space
characters matches <code class="inline">\<span class="i">B</span><span class="s">{</span><span class="w">wb</span><span class="s">}</span></code>
.)</p>
</li>
</ul>
<p>It is important to realize when you use these Unicode boundaries,
that you are taking a risk that a future version of Perl which contains
a later version of the Unicode Standard will not work precisely the same
way as it did when your code was written.  These rules are not
considered stable and have been somewhat more subject to change than the
rest of the Standard.  Unicode reserves the right to change them at
will, and Perl reserves the right to update its implementation to
Unicode's new rules.  In the past, some changes have been because new
characters have been added to the Standard which have different
characteristics than all previous characters, so new rules are
formulated for handling them.  These should not cause any backward
compatibility issues.  But some changes have changed the treatment of
existing characters because the Unicode Technical Committee has decided
that the change is warranted for whatever reason.  This could be to fix
a bug, or because they think better results are obtained with the new
rule.</p>
<p>It is also important to realize that these are default boundary
definitions, and that implementations may wish to tailor the results for
particular purposes and locales.  For example, some languages, such as
Japanese and Thai, require dictionary lookup to determine word
boundaries.</p>
<p>Mnemonic: <i>b</i>oundary.</p>
</li>
</ul>
<h4>Examples</h4>
<pre class="verbatim"><ol><li>  <span class="q">&quot;cat&quot;</span>   =~ <span class="q">/\Acat/</span><span class="sc">;</span>     <span class="c"># Match.</span></li><li>  <span class="q">&quot;cat&quot;</span>   =~ <span class="q">/cat\Z/</span><span class="sc">;</span>     <span class="c"># Match.</span></li><li>  <span class="q">&quot;cat\n&quot;</span> =~ <span class="q">/cat\Z/</span><span class="sc">;</span>     <span class="c"># Match.</span></li><li>  <span class="q">&quot;cat\n&quot;</span> =~ <span class="q">/cat\z/</span><span class="sc">;</span>     <span class="c"># No match.</span></li><li></li><li>  <span class="q">&quot;cat&quot;</span>   =~ <span class="q">/\bcat\b/</span><span class="sc">;</span>   <span class="c"># Matches.</span></li><li>  <span class="q">&quot;cats&quot;</span>  =~ <span class="q">/\bcat\b/</span><span class="sc">;</span>   <span class="c"># No match.</span></li><li>  <span class="q">&quot;cat&quot;</span>   =~ <span class="q">/\bcat\B/</span><span class="sc">;</span>   <span class="c"># No match.</span></li><li>  <span class="q">&quot;cats&quot;</span>  =~ <span class="q">/\bcat\B/</span><span class="sc">;</span>   <span class="c"># Match.</span></li><li></li><li>  <a class="l_k" href="functions/while.html">while</a> <span class="s">(</span><span class="q">&quot;cat dog&quot;</span> =~ <span class="q">/(\w+)/g</span><span class="s">)</span> <span class="s">{</span></li><li>      <a class="l_k" href="functions/print.html">print</a> <span class="i">$1</span><span class="sc">;</span>           <span class="c"># Prints &#39;catdog&#39;</span></li><li>  <span class="s">}</span></li><li>  <a class="l_k" href="functions/while.html">while</a> <span class="s">(</span><span class="q">&quot;cat dog&quot;</span> =~ <span class="q">/\G(\w+)/g</span><span class="s">)</span> <span class="s">{</span></li><li>      <a class="l_k" href="functions/print.html">print</a> <span class="i">$1</span><span class="sc">;</span>           <span class="c"># Prints &#39;cat&#39;</span></li><li>  <span class="s">}</span></li><li></li><li>  <a class="l_k" href="functions/my.html">my</a> <span class="i">$s</span> = <span class="q">&quot;He said, \&quot;Is pi 3.14? (I&#39;m not sure).\&quot;&quot;</span><span class="sc">;</span></li><li>  <a class="l_k" href="functions/print.html">print</a> <a class="l_k" href="functions/join.html">join</a><span class="s">(</span><span class="q">&quot;|&quot;</span><span class="cm">,</span> <span class="i">$s</span> =~ <span class="q">m/ ( .+? \b     ) /xg</span><span class="s">)</span><span class="cm">,</span> <span class="q">&quot;\n&quot;</span><span class="sc">;</span></li><li>  <a class="l_k" href="functions/print.html">print</a> <a class="l_k" href="functions/join.html">join</a><span class="s">(</span><span class="q">&quot;|&quot;</span><span class="cm">,</span> <span class="i">$s</span> =~ <span class="q">m/ ( .+? \b{wb} ) /xg</span><span class="s">)</span><span class="cm">,</span> <span class="q">&quot;\n&quot;</span><span class="sc">;</span></li><li> <span class="w">prints</span></li><li>  <span class="w">He</span>| |<span class="w">said</span>|<span class="cm">,</span> <span class="q">&quot;|Is| |pi| |3|.|14|? (|I|&#39;|m| |not| |sure</span></li><li>  <span class="q">  He| |said|,| |&quot;</span>|<span class="w">Is</span>| |<span class="w">pi</span>| |<span class="n">3.14</span>|<span class="q">?| |(|I&#39;m| |not| |sure|)|.|&quot;</span></li></ol></pre><a name="Misc"></a><h2>Misc</h2>
<p>Here we document the backslash sequences that don't fall in one of the
categories above. These are:</p>
<ul>
<li><a name="%5cK"></a><b>\K</b>
<p>This appeared in perl 5.10.0. Anything matched left of <code class="inline">\<span class="w">K</span></code>
 is
not included in <code class="inline"><span class="i">$&amp;</span></code>
, and will not be replaced if the pattern is
used in a substitution. This lets you write <code class="inline"><span class="q">s/PAT1 \K PAT2/REPL/x</span></code>

instead of <code class="inline"><span class="q">s/(PAT1) PAT2/${1}REPL/x</span></code>
 or <code class="inline"><span class="q">s/(?&lt;=PAT1) PAT2/REPL/x</span></code>
.</p>
<p>Mnemonic: <i>K</i>eep.</p>
</li>
<li><a name="%5cN"></a><b>\N</b>
<p>This feature, available starting in v5.12,  matches any character
that is <b>not</b> a newline.  It is a short-hand for writing <code class="inline">[^\n]</code>, and is
identical to the <code class="inline">.</code> metasymbol, except under the <code class="inline">/s</code> flag, which changes
the meaning of <code class="inline">.</code>, but not <code class="inline">\<span class="w">N</span></code>
.</p>
<p>Note that <code class="inline">\<span class="i">N</span><span class="s">{</span>...<span class="s">}</span></code>
 can mean a
<a href="#Named-or-numbered-characters-and-character-sequences">named or numbered character </a>.</p>
<p>Mnemonic: Complement of <i>\n</i>.</p>
</li>
<li><a name="%5cR"></a><b>\R
</b>
<p><code class="inline">\<span class="w">R</span></code>
 matches a <i>generic newline</i>; that is, anything considered a
linebreak sequence by Unicode. This includes all characters matched by
<code class="inline">\<span class="w">v</span></code>
 (vertical whitespace), and the multi character sequence <code class="inline"><span class="q">&quot;\x0D\x0A&quot;</span></code>

(carriage return followed by a line feed, sometimes called the network
newline; it's the end of line sequence used in Microsoft text files opened
in binary mode). <code class="inline">\<span class="w">R</span></code>
 is equivalent to <code class="inline"><span class="s">(</span><span class="q">?&gt;\x0D\x0A|\v)</span></code>
.  (The
reason it doesn't backtrack is that the sequence is considered
inseparable.  That means that</p>
<pre class="verbatim"><ol><li> <span class="q">&quot;\x0D\x0A&quot;</span> =~ <span class="q">/^\R\x0A$/</span>   <span class="c"># No match</span></li></ol></pre><p>fails, because the <code class="inline">\<span class="w">R</span></code>
 matches the entire string, and won't backtrack
to match just the <code class="inline"><span class="q">&quot;\x0D&quot;</span></code>
.)  Since
<code class="inline">\<span class="w">R</span></code>
 can match a sequence of more than one character, it cannot be put
inside a bracketed character class; <code class="inline"><span class="q">/[\R]/</span></code>
 is an error; use <code class="inline">\<span class="w">v</span></code>

instead.  <code class="inline">\<span class="w">R</span></code>
 was introduced in perl 5.10.0.</p>
<p>Note that this does not respect any locale that might be in effect; it
matches according to the platform's native character set.</p>
<p>Mnemonic: none really. <code class="inline">\<span class="w">R</span></code>
 was picked because PCRE already uses <code class="inline">\<span class="w">R</span></code>
,
and more importantly because Unicode recommends such a regular expression
metacharacter, and suggests <code class="inline">\<span class="w">R</span></code>
 as its notation.</p>
</li>
<li><a name="%5cX"></a><b>\X
</b>
<p>This matches a Unicode <i>extended grapheme cluster</i>.</p>
<p><code class="inline">\<span class="w">X</span></code>
 matches quite well what normal (non-Unicode-programmer) usage
would consider a single character.  As an example, consider a G with some sort
of diacritic mark, such as an arrow.  There is no such single character in
Unicode, but one can be composed by using a G followed by a Unicode "COMBINING
UPWARDS ARROW BELOW", and would be displayed by Unicode-aware software as if it
were a single character.</p>
<p>The match is greedy and non-backtracking, so that the cluster is never
broken up into smaller components.</p>
<p>See also <a href="#%5cb%7b%7d%2c-%5cb%2c-%5cB%7b%7d%2c-%5cB">\b{gcb} </a>.</p>
<p>Mnemonic: e<i>X</i>tended Unicode character.</p>
</li>
</ul>
<h4>Examples</h4>
<pre class="verbatim"><ol><li> <span class="i">$str</span> =~ <span class="q">s/foo\Kbar/baz/g</span><span class="sc">;</span> <span class="c"># Change any &#39;bar&#39; following a &#39;foo&#39; to &#39;baz&#39;</span></li><li> <span class="i">$str</span> =~ <span class="q">s/(.)\K\g1//g</span><span class="sc">;</span>    <span class="c"># Delete duplicated characters.</span></li><li></li><li> <span class="q">&quot;\n&quot;</span>   =~ <span class="q">/^\R$/</span><span class="sc">;</span>         <span class="c"># Match, \n   is a generic newline.</span></li><li> <span class="q">&quot;\r&quot;</span>   =~ <span class="q">/^\R$/</span><span class="sc">;</span>         <span class="c"># Match, \r   is a generic newline.</span></li><li> <span class="q">&quot;\r\n&quot;</span> =~ <span class="q">/^\R$/</span><span class="sc">;</span>         <span class="c"># Match, \r\n is a generic newline.</span></li><li></li><li> <span class="q">&quot;P\x{307}&quot;</span> =~ <span class="q">/^\X$/</span>     <span class="c"># \X matches a P with a dot above.</span></li></ol></pre>



  <div id="page_index" class="hud_container">
    <div id="page_index_header" class="hud_header">
      <div id="page_index_close" class="hud_close"><a href="#" onClick="pageIndex.hide();return false;"></a></div>
      <div id="page_index_title" class="hud_title"><span class="hud_span_top">Page index</span></div>
      <div id="page_index_topright" class="hud_topright"></div>
    </div>
    <div id="page_index_content" class="hud_content">
      <ul><li><a href="#NAME">NAME</a><li><a href="#DESCRIPTION">DESCRIPTION</a><ul><li><a href="#The-backslash">The backslash</a><li><a href="#All-the-sequences-and-escapes">All the sequences and escapes</a><li><a href="#Character-Escapes">Character Escapes</a><li><a href="#Modifiers">Modifiers</a><li><a href="#Character-classes">Character classes</a><li><a href="#Referencing">Referencing</a><li><a href="#Assertions">Assertions</a><li><a href="#Misc">Misc</a></ul></ul>
    </div>
    <div id="page_index_footer" class="hud_footer">
      <div id="page_index_bottomleft" class="hud_bottomleft"></div>
      <div id="page_index_bottom" class="hud_bottom"><span class="hud_span_bottom"></span></div>
      <div id="page_index_resize" class="hud_resize"></div>
    </div>
  </div>


	    &nbsp;
          </div>
          <div id="content_footer">
          </div>
        </div>
        <div class="clear"></div>
      </div>
      
    <div id="footer">
      <div id="footer_content">
        <div id="footer_strapline">
          perldoc.perl.org - Official documentation for the Perl programming language
        </div>
        <div id="footer_links">
          <div id="address">
            <p class="name">Contact details</p>
            <p class="address">
	      Site maintained by <a href="mailto:jj@jonallen.info">Jon Allen (JJ)</a><br>
	    </p>
            <p class="contact">
              Documentation maintained by the <a href="http://lists.cpan.org/showlist.cgi?name=perl5-porters">Perl 5 Porters</a>
            </p>
          </div>
          <ul class="f1">
            <li>Manual
              <ul class="f2">
                <li><a href="index-overview.html">Overview</a>
                <li><a href="index-tutorials.html">Tutorials</a>
                <li><a href="index-faq.html">FAQs</a>
                <li><a href="index-history.html">Changes</a>
              </ul>
            <li>Reference
              <ul class="f2">
                <li><a href="index-language.html">Language</a>
                <li><a href="index-functions.html">Functions</a>
                <li><a href="perlop.html">Operators</a>
                <li><a href="perlvar.html">Variables</a>
              </ul>
            <li>Modules
              <ul class="f2">
                <li><a href="index-modules-A.html">Modules</a>
                <li><a href="index-pragmas.html">Pragmas</a>
                <li><a href="index-utilities.html">Utilities</a>
              </ul>
            <li>Misc
              <ul class="f2">
                <li><a href="index-licence.html">License</a>
                <li><a href="index-internals.html">Internals</a>
                <li><a href="index-platforms.html">Platforms</a>
              </ul>          </ul>
          <div class="clear"></div>
        </div>
      </div>
      <div id="footer_end">
      </div>
    </div>
      
    </div>
      <script language="JavaScript" type="text/javascript" src="static/exploreperl.js"></script>
      <script language="JavaScript" src="static/combined-20100403.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
  perldoc.setPath(0);
  perldoc.pageName    = 'perlrebackslash';
  perldoc.pageAddress = 'perlrebackslash.html';
  perldoc.contentPage = 1;
  explorePerl.render();
  explorePerl.addEvents('explore_anchor');
</script>
    
  </body>
</html>