We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As discussed on the lambdaisland channel of the clojurians slack (https://clojurians.slack.com/archives/C1DV21X9P/p1643329544995089)
I'm trying to replicate this in regal using a backrefernce to match any 3 or more of the same consecutive character: ;;=> ["1111" "1"]``` But can't seem to get it: ```(regal/regex [:cat [:capture :any] [:repeat ::_ 3 nil]] {:resolver (fn [x] "\\1")}) ;;=> #"(.)(?:\\1){3,}" (regal/regex [:capture [:capture :any] [:repeat ::_ 3 nil]] {:resolver (fn [x] "\1")}) ;;=> #"((.){3,})" (regal/regex [:capture [:capture :any] [:repeat ::_ 3 nil]] {:resolver (fn [x] "\\\\1")}) ;;=> #"((.)(?:\\\\1){3,})"``` Any tips?
I'm trying to replicate this in regal using a backrefernce to match any 3 or more of the same consecutive character:
;;=> ["1111" "1"]``` But can't seem to get it: ```(regal/regex [:cat [:capture :any] [:repeat ::_ 3 nil]] {:resolver (fn [x] "\\1")}) ;;=> #"(.)(?:\\1){3,}" (regal/regex [:capture [:capture :any] [:repeat ::_ 3 nil]] {:resolver (fn [x] "\1")}) ;;=> #"((.){3,})" (regal/regex [:capture [:capture :any] [:repeat ::_ 3 nil]] {:resolver (fn [x] "\\\\1")}) ;;=> #"((.)(?:\\\\1){3,})"``` Any tips?
@plexus Responded:
(ns repl-sessions.poke (:require [lambdaisland.regal :as regal] [lambdaisland.regal.parse :as regal-parse])) (regal-parse/parse #"(.)\1{3,}") ;; => [:cat ;; [:capture :any] ;; [:repeat [:lambdaisland.regal.parse/not-implemented [:BackReference "1"]] 3]] backreferences aren't implemented, but seems like a common enough feature that they should be. Would you mind creating a ticket? here's a workaround you can do yourself: (defmethod regal/-regal->ir [:ref :common] [[op idx] opts] `^::regal/grouped ("\\" ~(str idx))) (regal/regex [:cat [:capture :any] [:repeat [:ref 1] 3 nil]]) ;; => #"(.)\1{3,}"
(ns repl-sessions.poke (:require [lambdaisland.regal :as regal] [lambdaisland.regal.parse :as regal-parse])) (regal-parse/parse #"(.)\1{3,}") ;; => [:cat ;; [:capture :any] ;; [:repeat [:lambdaisland.regal.parse/not-implemented [:BackReference "1"]] 3]]
backreferences aren't implemented, but seems like a common enough feature that they should be. Would you mind creating a ticket?
here's a workaround you can do yourself:
(defmethod regal/-regal->ir [:ref :common] [[op idx] opts] `^::regal/grouped ("\\" ~(str idx))) (regal/regex [:cat [:capture :any] [:repeat [:ref 1] 3 nil]]) ;; => #"(.)\1{3,}"
It was also questioned if all engines, Java, ECMA, Re2 support this. It looks the like the first two do but Re2 doesn't google/re2#101
The text was updated successfully, but these errors were encountered:
Unlike the other missing features, I think these are relatively frequently useful so I"m going to keep this open.
Sorry, something went wrong.
No branches or pull requests
As discussed on the lambdaisland channel of the clojurians slack (https://clojurians.slack.com/archives/C1DV21X9P/p1643329544995089)
@plexus Responded:
It was also questioned if all engines, Java, ECMA, Re2 support this. It looks the like the first two do but Re2 doesn't
google/re2#101
The text was updated successfully, but these errors were encountered: