[erlang-questions] How to detect \. in Markdown string
Richard A. O'Keefe
ok@REDACTED
Wed Jun 21 07:13:48 CEST 2017
> On 21/06/2017, at 5:03 PM, <lloyd@REDACTED> <lloyd@REDACTED> wrote:
>
> But darned if I can find an Erlang function to distinguish these two cases:
>
> 2> S = "1986\. What a great season.".
> "1986. What a great season."
\. is just dot. If you want a \ in there, you need \\.
T = "1986\\. What a great season."
> 3>
> 3> string:chr(S, "\.").
As the name suggests, string:chr wants a *character* as
its second argument. You have given it a *string*.
1> T = "1986\\. What a great season.".
"1986\\. What a great season."
2> string:chr(T, $.).
6
3> string:str(T, "\\.").
5
The Erlang reference manual, section 3.15, lists all the
defined character escape sequences. Anything NOT in
that list is NOT a defined escape sequence and you use
it at your peril. It is a pity that sequences like \.
and \E are not reported as errors or at least warnings.
More information about the erlang-questions
mailing list