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
0
160
Perl 6 Regex
features and syntax of the new reformed Perl Regular Expression
lichtkind
September 05, 2015
Tweet
Share
More Decks by lichtkind
See All by lichtkind
Perl 6 in context
lichtkind
0
62
Perl 6 OOP
lichtkind
0
190
Perl 6 data structures
lichtkind
0
110
functional Perl 6
lichtkind
0
570
Other Decks in Programming
See All in Programming
slow types ってなんだろう?
karad
0
210
TypeScript 関数型スタイルでバックエンド開発のリアル
naoya
49
16k
Next.js App Router
quramy
14
2.3k
RailsConf 2024: Riffing on Rails: sketch your way to better designed code
kaspth
1
210
RubyGems on ruby.wasm
kateinoigakukun
0
110
GitHub Actionsの痒いところを埋めるサードパーティーランナー
dora1998
2
250
ソースコードを美しくたもつために ~コードレビューの認知限界を突破し、年間400リリースを達成する~
kotauchisunsun
1
720
TypeScriptの型とパフォーマンス (TSKaigi 2024)
ypresto
14
4.4k
Revisiting the Hotwire Landscape after Turbo 8 @ RailsConf 2024, Detroit
marcoroth
3
610
Go製Webアプリケーションのエラーとの向き合い方大全、あるいはやっぱりスタックトレース欲しいやん / Kyoto.go #50
utgwkk
6
2k
PHPコードの実行モデルを理解する / Understanding-the-PHP-Execution-Model
shin1x1
0
1.1k
Jetpack Composeとデザインシステム
rmakiyama
0
230
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
92
4.8k
The Art of Programming - Codeland 2020
erikaheidi
43
12k
Ruby is Unlike a Banana
tanoku
96
10k
Product Roadmaps are Hard
iamctodd
45
9.8k
We Have a Design System, Now What?
morganepeng
43
6.8k
Practical Orchestrator
shlominoach
183
9.8k
Debugging Ruby Performance
tmm1
70
11k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
21
2k
The Invisible Side of Design
smashingmag
294
49k
Producing Creativity
orderedlist
PRO
338
39k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
51k
KATA
mclloyd
16
12k
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