Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Perl 6 Regex
Search
lichtkind
September 05, 2015
Programming
180
0
Share
Perl 6 Regex
features and syntax of the new reformed Perl Regular Expression
lichtkind
September 05, 2015
More Decks by lichtkind
See All by lichtkind
Perl 6 in context
lichtkind
0
73
Perl 6 OOP
lichtkind
0
230
Perl 6 data structures
lichtkind
0
150
functional Perl 6
lichtkind
0
830
Other Decks in Programming
See All in Programming
Inspired By RubyKaigi (EN)
atzzcokek
0
490
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
140
次世代リンターで探る、tsgo 時代における型認識カスタムルールの現実解
ytakahashii
3
1.4k
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
120
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
180
RTSPクライアントを自作してみた話
simotin13
0
420
権限チェックの一貫性を型で守る TypeScript による多層防御
mnch
4
1.1k
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
330
ふつうのFeature Flag実践入門
irof
7
3.5k
AI駆動開発勉強会 広島支部 第一回勉強会 AI駆動開発概要とワークショップ
hayatoshimiu
0
430
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
550
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
240
Featured
See All Featured
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
150
Paper Plane (Part 1)
katiecoart
PRO
0
8.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
530
Prompt Engineering for Job Search
mfonobong
0
330
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
200
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
300
Evolving SEO for Evolving Search Engines
ryanjones
0
210
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
Transcript
Perl 6 regex
Perl 6 regex In search for perfection
Much is Gone
Something Stayed ops: m//, s/// , tr/// mods: i, g
capturing: (…) escape: \ quantifier: *, +, ? min. match. suffix: ??, *?, +? alternatives: | match var.: $1 .. $9
Operators
Create A Regex rx/.../
It's The New qr// rx/.../
Apply Rx ~~
Known Since 5.10 ~~
Still Changing In 5.18 ~~
Apply Rx ~~ no more =~
Known Operators m// s///
Rx Methods match comb subst
New Operators ms// ss///
Aliases For: m :s// s :ss///
Modifiers
Modifiers no x
Modifiers no x m s
Modifiers no s e x
Modifiers no s ee x
Modifiers P5 Perl5
Modifiers :P5 :Perl5
Modifiers ~~ m :P5 /.../
Match All :g :global
Match n Times :x(n)
Just nth Match :nth(n)
Search from Pos On :c(n) :continue(n)
Search Only On Pos :p(n) :pos(n)
Spaces Have Meaning :s :sigspace :ss :samespace
Like qw// Only Smarter :s :sigspace :ss :samespace
Lower Line Is For s/// :s :sigspace :ss :samespace
Modifiers :i :ignorecase :ii :samecase
Modifiers :m :ignoremark :mm :samemark
Choose A Level :bytes :chars :codes :graphs
Metachar
Metachar .
Metachar . any char
Metachar .
Metachar .
No Output In Perl 5 perl -e 'print 1 if
"\n"=~ /./
Do Output In Perl 6 perl6 -e 'say 1 if
"\n"~~ /./
Metachar . any char
Metachar \N not a newline
Metachar ^ $ You know that
Metachar ^^ $$ linewise
'a' Wins In Perl 5 perl -E '"ab"=~ /(a|ab)/;say $1'
'ab' Wins In Perl 6 perl6 -E '"ab"~~/(a|ab)/;say $0'
Metachar | longest wins
Metachar || first wins
Metachar () capt. groups
Metachar [ ] nonecapturing groups
Metachar <[ ]> char classes
Metachar \s space
Metachar \s = \h | \v horizont. or vertic.
Metachar \s = \h | \v \r \n and alike
Metachar \s = \h | \v Spaces, tabs(\t) and alike
Quantifiers
Quantifiers simple have not changed
Five Digits \d ** 5
Five Digits \d ** 5 '12345'
Two to Five Digits \d ** 2..5
Colon Seperated Digits \d+ % ','
Colon Seperated Digits \d+ % ',' '1,2,3,4'
+ Trailing Seperator \d+ %% ',' '1,2,3,4,'
Combined \d ** 2..* % ','
Special Var
Match Object $/ last sucessful Match
Named Submatch $/ $/<...>
Named Submatch $/ $/{'...'} $<...>
List Of Matches @()
List Of Matches @() @() = $0 ..
List Of Matches @()[n] @() = $0 .. (no limit)
AoA Of Matches @()[1][2] .(.).(.(.).(.).(...).).
Learn More http://perlcabal.org /syn/S05.html
Thank You