Alternative regex solution?

Q&A's, tips, howto's

Alternative regex solution?

Postby reinier maliepaard » Fri Jul 26, 2013 10:21 am

Hello,

The following code adds to one or more apostroph's a backslash only when the (first) apostroph is preceded by a lowercase letter. My two-step-solution works, but I -newLisp newbie- have doubts on it. Does someone has a better idea? Thanks in advance.

Regards,
Reinier
...............................................................
(setq mcString "C''' g''''' c' A''")

;first step
(replace "([a-g])([']+)" mcString (append $1 "\\" $2) 0)

;second step
(while (find "\\''" mcString)
(replace "\\''" mcString "\\'\\'")
)

;result is ok: C''' g\'\'\'\'\' c\' A''
(println "result: " mcString)
...............................................................
reinier maliepaard
 
Posts: 6
Joined: Fri Jul 05, 2013 5:34 pm

Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron