May be this questions is really stuped, but I'm stuck. How can I put backslashes in cl-ppcre:regex-replace-all
replacement?
For example I just want to escape some characters like ' " ( ) etc, so I'm going to do with | replacement first, to see that matching is ok:
CL-USER> (princ (cl-ppcre:regex-replace-all "(['\\(\\)\"])"
"foo \"bar\" 'baz' (test)" "|\\1"))
PRINTED: foo |"bar|" |'baz|' |(test|)
Ok, let's put slash:
CL-USER> (princ (cl-ppcre:regex-replace-all "(['\\(\\)\"])"
"foo \"bar\" 'baz' (test)" "\\\1"))
PRINTED: foo "bar" 'baz' (test) ;; No luck
No, we nedd two slashes:
CL-USER> (princ (cl-ppcre:regex-replace-all "(['\\(\\)\"])"
"foo \"bar\" 'baz' (test)" "\\\\1"))
PRINTED: foo \1bar\1 \1baz\1 \1test\1 ;; Got slash, but not \1
Maybe like this?
(princ (cl-ppcre:regex-replace-all "(['\\(\\)\"])"
"foo \"bar\" 'baz' (test)" "\\\{1}"))
PRINTED: foo "bar" 'baz' (test) ;; Nope, no luck here
Of course, if I'll put space between slashes everithing is ok, but I don't need it
(princ (cl-ppcre:regex-replace-all "(['\\(\\)\"])"
"foo \"bar\" 'baz' (test)" "\\ \\1"))
PRINTED: foo \ "bar\ " \ 'baz\ ' \ (test\ )
So, how can i write to get foo \"bar\" \'baz\' \(test\)
printed? Thanks.