[erlang-questions] regexp behaviour

Robert Virding rvirding@REDACTED
Sat Mar 15 21:15:37 CET 2008


Hi,

If you quote the '&' character with \ then you will get a & in the out put
string. So

Str1 = "String with \\& character"

N.B. you need an extra \ because it is in a string and the string parsing
converts \\ into \ in the resultant string.

Robert

On 15/03/2008, shehan <shehan@REDACTED> wrote:
>
>  Hi all,
>
>
>
> Is the some way to stop the following behaviour of the "sub" function in
> the "regexp" module
>
>
>
> Str1 = "String with & character"
>
> Str2 = "Replace the following tag <replace> with str1"
>
>
>
> regexp:sub(Str2, "<replace>", Str1).
>
>
>
>
>
> {ok, NewStr, Count} = regexp:gsub(Str1, ["<ad2>"], Ad2).
>
> NewStr.
>
> "Replace the following tag String with <replace> character with str1"
>
>
>
> The <replace> is replaced by the content of Str1, but the & character in
> Str1 has been replaced by the
>
> replaced character set <replace>. is there some way to stop this from
> happening.
>
>
>
> Thanx
>
> Shehan
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080315/9a6a5e90/attachment.htm>


More information about the erlang-questions mailing list