[Swift-user] backslash quoting in strings
Ben Clifford
benc at hawaga.org.uk
Sat Nov 15 19:42:28 CST 2008
On Sat, 15 Nov 2008, Michael Wilde wrote:
> It seems from experimentation that backslash quoting changed at some point (or
> the user guide and tutorial are wrong): the \1 needed in the transform arg of
> the regexp_mapper needs to be \\1 - at least it seems this way from
> experimentation with trace().
Yes, that changed between v0.4 and v0.5.
This is an intended behaviour, to facilitate putting in \" characters.
> Its also odd trace() takes \t and \n but echoes them just like that, with the
> backslashes printing.
I don't think has had any strong intention about that should behave.
On looking at the parser, \ followed by one of n r t b f " \ will be
passed through, with apparently only the quotes having some special
behaviour and the others passing through unmodified. Other \ sequences,
such as \g, will cause a parser error.
This could be tidied up sometime. File a bug for it.
--
More information about the Swift-user
mailing list