ashinn / chibi-scheme

Official chibi-scheme repository
Other
1.2k stars 142 forks source link

Regex that should work just doesn't #952

Closed brainlessbitch closed 3 months ago

brainlessbitch commented 3 months ago

this is my code

(regexp-replace-all '("#{1}\\s?([^\\n]+)") markdown "<h1>\\1</h1>")

but all i get out is like <h1>\1</h1> Hello, world!, am i doing something wrong or is it a problem with chibi? (if you're wondering, i'm making a markdown to html parser)

ashinn commented 3 months ago

The syntax may look like that in other languages, but Chibi uses SRFI 115 SREs:

(regexp-replace-all
  '(: "#{1}" (* space) ($ (~ space) (+ nonl)))
  "#{1} Hello world"
  '("<h1>" 1 "</h1>"))
=> "<h1>Hello world</h1>"
brainlessbitch commented 3 months ago

OHHHH thank you so much, i never woulda figured that out lol