Skip to main content

Reusing and Composing Regexes

  • Chapter
  • First Online:
Parsing with Perl 6 Regexes and Grammars
  • 777 Accesses

Abstract

Perl 6 offers great tools for composing regexes, thus making them reusable. This inspires programmers to carefully organize and test their regexes, just like regular code.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 16.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Perl 6 has a built-in type called byte , so if you leave out the ampersand, you’ll accidentally reference this type instead.

  2. 2.

    In Python, it’s even more complicated, since whitespace at the start of a line is significant, except when it’s inside an expression.

  3. 3.

    The assertion <!ww> matches every exception within a word.

  4. 4.

    Remember that the leading dot in <.ws> causes the regex not to capture. Since the ws routine is all about whitespace that we don’t particularly care about, not capturing its match makes sense.

  5. 5.

    https://docs.perl6.org/type/Grammar

  6. 6.

    https://en.wikipedia.org/wiki/SQL

  7. 7.

    http://json.org/

  8. 8.

    https://github.com/moritz/json/

  9. 9.

    https://github.com/moritz/json/blob/master/lib/JSON/Tiny/Grammar.pm

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Moritz Lenz

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Lenz, M. (2017). Reusing and Composing Regexes. In: Parsing with Perl 6 Regexes and Grammars. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3228-6_8

Download citation

Publish with us

Policies and ethics