Skip to content

A PEG that matches a number of at least two digits and ends with a specific digit? #1455

Closed Answered by sogaiu
stutonk asked this question in Q&A
Discussion options

You must be logged in to vote

As requested in this comment, here's an alternative peg:

~(sequence :d+ (look -1 "0"))

I confess to have seen something like it in bakpakin's code (^^;

> below is an alias for look IIUC:

      :long-bytes '{:delim (some "`")
                    :open (capture :delim :n)
                    :close (cmt (* (not (> -1 "`")) (-> :n) ':delim) ,=)
                    :main (drop (* :open (any (if-not :close 1)) :close))}

via: code in spork/fmt

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
4 replies
@sogaiu
Comment options

@CFiggers
Comment options

@pepe
Comment options

@stutonk
Comment options

Comment options

You must be logged in to vote
3 replies
@pepe
Comment options

@stutonk
Comment options

@sogaiu
Comment options

Answer selected by stutonk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants