-
Notifications
You must be signed in to change notification settings - Fork 45
Capture groups with regexes using positive lookahead #54
Copy link
Copy link
Open
Description
How can I get all the captured groups with the following positive lookahead regex?
My attempts:
(ppcre:all-matches-as-strings "(?=one|two|three|four|five|six|seven|eight|nine|ten)" "eighthree") ; => ("" "")
(ppcre:all-matches-as-strings "(?=(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine))" "eighthree") ; => ("" "")
(ppcre:scan-to-strings "(?=(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine))" "eighthree") ; => "" #(NIL NIL NIL NIL NIL NIL NIL "eight" NIL)
(ppcre:scan-to-strings "(?=(one|two|three|four|five|six|seven|eight|nine|ten))" "eighthree") ; => "" #("eight")
(cl-ppcre:register-groups-bind
(one two three four five six seven eight nine)
("(?=(one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine))" "eighthree" :sharedp t)
(remove nil (list one two three four five six seven eight nine))) ; => ("eight")You can get both groups using regex101 for example:
https://regex101.com/r/mJmQwA/1
https://regex101.com/r/XTw3x7/1

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels