SlideShare a Scribd company logo
1 of 74
Download to read offline
Perl 6 regex
Perl 6 regex


In search for perfection
Many Things Gone
Some Stayed
 capturing: (…) escape: 
         mods: i, g
     quantifier: *, +, ?
       alternatives: |
      match var.: $/
min. match. suffix: ??, *?, +?
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 =~
Operators


m// s///
Rx Methods

match comb
  subst
Operators


ms// ss///
Operators


m :s// s :ss///
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 /.../
Modifiers


:g :global
Match x 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

More Related Content

What's hot

Sequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experimentSequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experiment
Gouthaman V
 
Csc1100 lecture05 ch05
Csc1100 lecture05 ch05Csc1100 lecture05 ch05
Csc1100 lecture05 ch05
IIUM
 
Csc1100 lecture06 ch06_pt2
Csc1100 lecture06 ch06_pt2Csc1100 lecture06 ch06_pt2
Csc1100 lecture06 ch06_pt2
IIUM
 
TDD Boot Camp 東京 for C++ 進行
TDD Boot Camp 東京 for C++ 進行TDD Boot Camp 東京 for C++ 進行
TDD Boot Camp 東京 for C++ 進行
Takashi Imagire
 
Csc1100 lecture06 ch06_pt1
Csc1100 lecture06 ch06_pt1Csc1100 lecture06 ch06_pt1
Csc1100 lecture06 ch06_pt1
IIUM
 

What's hot (14)

Linked list Output tracing
Linked list Output tracingLinked list Output tracing
Linked list Output tracing
 
Sequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experimentSequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experiment
 
Presentation1
Presentation1Presentation1
Presentation1
 
Lisp tutorial
Lisp tutorialLisp tutorial
Lisp tutorial
 
String matching with finite state automata
String matching with finite state automataString matching with finite state automata
String matching with finite state automata
 
Csc1100 lecture05 ch05
Csc1100 lecture05 ch05Csc1100 lecture05 ch05
Csc1100 lecture05 ch05
 
Csc1100 lecture06 ch06_pt2
Csc1100 lecture06 ch06_pt2Csc1100 lecture06 ch06_pt2
Csc1100 lecture06 ch06_pt2
 
Introduction to SkyPat 2.0
Introduction to SkyPat 2.0Introduction to SkyPat 2.0
Introduction to SkyPat 2.0
 
TDD Boot Camp 東京 for C++ 進行
TDD Boot Camp 東京 for C++ 進行TDD Boot Camp 東京 for C++ 進行
TDD Boot Camp 東京 for C++ 進行
 
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)
 
Csc1100 lecture06 ch06_pt1
Csc1100 lecture06 ch06_pt1Csc1100 lecture06 ch06_pt1
Csc1100 lecture06 ch06_pt1
 
Garbage Collection
Garbage CollectionGarbage Collection
Garbage Collection
 

Viewers also liked

Viewers also liked (9)

P6oo
P6ooP6oo
P6oo
 
Modern wx perl
Modern wx perlModern wx perl
Modern wx perl
 
Perl 5 Quiz Chemnitz Edition
Perl 5 Quiz Chemnitz EditionPerl 5 Quiz Chemnitz Edition
Perl 5 Quiz Chemnitz Edition
 
Complete Programming
Complete ProgrammingComplete Programming
Complete Programming
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
(Parameterized) Roles
(Parameterized) Roles(Parameterized) Roles
(Parameterized) Roles
 
Perl 5.20: Feature, Kultur, Module, Werkzeuge
Perl 5.20: Feature, Kultur, Module, WerkzeugePerl 5.20: Feature, Kultur, Module, Werkzeuge
Perl 5.20: Feature, Kultur, Module, Werkzeuge
 
P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6
 

Similar to Writing Perl 6 Rx

Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisa
ujihisa
 
Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)
ujihisa
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
Sway Wang
 

Similar to Writing Perl 6 Rx (20)

Parboiled explained
Parboiled explainedParboiled explained
Parboiled explained
 
Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
Parsers Combinators in Scala, Ilya @lambdamix Kliuchnikov
Parsers Combinators in Scala, Ilya @lambdamix KliuchnikovParsers Combinators in Scala, Ilya @lambdamix Kliuchnikov
Parsers Combinators in Scala, Ilya @lambdamix Kliuchnikov
 
Regular Expressions: JavaScript And Beyond
Regular Expressions: JavaScript And BeyondRegular Expressions: JavaScript And Beyond
Regular Expressions: JavaScript And Beyond
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisa
 
lisps - A Lisp Interpreter written in Postscript
lisps - A Lisp Interpreter written in Postscriptlisps - A Lisp Interpreter written in Postscript
lisps - A Lisp Interpreter written in Postscript
 
And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...
 
Mastering Grammars with PetitParser
Mastering Grammars with PetitParserMastering Grammars with PetitParser
Mastering Grammars with PetitParser
 
Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)
 
Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....
 
Unicode Regular Expressions
Unicode Regular ExpressionsUnicode Regular Expressions
Unicode Regular Expressions
 
UNIX - Class5 - Advance Shell Scripting-P2
UNIX - Class5 - Advance Shell Scripting-P2UNIX - Class5 - Advance Shell Scripting-P2
UNIX - Class5 - Advance Shell Scripting-P2
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
 
Use PEG to Write a Programming Language Parser
Use PEG to Write a Programming Language ParserUse PEG to Write a Programming Language Parser
Use PEG to Write a Programming Language Parser
 
Out with Regex, In with Tokens
Out with Regex, In with TokensOut with Regex, In with Tokens
Out with Regex, In with Tokens
 
Implementing External DSLs Using Scala Parser Combinators
Implementing External DSLs Using Scala Parser CombinatorsImplementing External DSLs Using Scala Parser Combinators
Implementing External DSLs Using Scala Parser Combinators
 
Linux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regxLinux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regx
 
Ch2 (1).ppt
Ch2 (1).pptCh2 (1).ppt
Ch2 (1).ppt
 

More from lichtkind

Bettereditors
BettereditorsBettereditors
Bettereditors
lichtkind
 

More from lichtkind (16)

Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
 
Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smart
 
P6kontext2014
P6kontext2014P6kontext2014
P6kontext2014
 
Wundertüte Perl
Wundertüte PerlWundertüte Perl
Wundertüte Perl
 
Perl 6 Regex und Grammars
Perl 6 Regex und GrammarsPerl 6 Regex und Grammars
Perl 6 Regex und Grammars
 
Perl 6 Datastructures
Perl 6 DatastructuresPerl 6 Datastructures
Perl 6 Datastructures
 
Perl 6 Datenstrukturen
Perl 6 DatenstrukturenPerl 6 Datenstrukturen
Perl 6 Datenstrukturen
 
Document Driven Development
Document Driven DevelopmentDocument Driven Development
Document Driven Development
 
Bettereditors
BettereditorsBettereditors
Bettereditors
 
Hgit
HgitHgit
Hgit
 
Was können wir von Rebol lernen?
Was können wir von Rebol lernen?Was können wir von Rebol lernen?
Was können wir von Rebol lernen?
 
Neuperl6
Neuperl6Neuperl6
Neuperl6
 
Perl Testing
Perl TestingPerl Testing
Perl Testing
 
Perl in der Wiki
Perl in der WikiPerl in der Wiki
Perl in der Wiki
 
What is Kephra about?
What is Kephra about?What is Kephra about?
What is Kephra about?
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Writing Perl 6 Rx