Skip to main content

Introducing new learning courses and educational videos from Apress. Start watching

Reusing and Composing Regexes

  • 717 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.

Keywords

  • JSON Value
  • Select Sales
  • Token Byte
  • Item Value
  • Whitespace

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

This is a preview of subscription content, access via your institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • DOI: 10.1007/978-1-4842-3228-6_8
  • Chapter length: 18 pages
  • Instant PDF download
  • Readable on all devices
  • Own it forever
  • Exclusive offer for individuals only
  • Tax calculation will be finalised during checkout
eBook
USD   29.99
Price excludes VAT (USA)
  • ISBN: 978-1-4842-3228-6
  • Instant PDF download
  • Readable on all devices
  • Own it forever
  • Exclusive offer for individuals only
  • Tax calculation will be finalised during checkout
Softcover Book
USD   37.99
Price excludes VAT (USA)

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

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