escaping values for re:replace

Wes James comptekki@REDACTED
Tue Jul 27 22:53:24 CEST 2010


I created a function:

escape(S) ->
	S2=re:replace(S, "\\*", "\\\\*", [{return,list}, global]),
	S3=re:replace(S2, "\\[", "\\\\[", [{return,list}, global]),
	S4=re:replace(S3, "\\(", "\\\\(", [{return,list}, global]),
	re:replace(S4, "\\)", "\\\\)", [{return,list}, global]).

to escape the values I know. Is there a more erlang way to do this?
I'm trying to replace all *, [, (, ) with the escaped values.

thx,

-wes


More information about the erlang-questions mailing list