[erlang-questions] String pattern matching

Robert Virding rvirding@REDACTED
Wed Apr 29 01:18:02 CEST 2009

A string is just a list and unfortunately you can only match against the
front of the list so there is no pattern with which you can test for/remove
\r\n from the end of a string. This also means that the results of using the
patterns you gave is perfectly logical:

- "a"++B is a list/string where the beginning is "a" and the rest of the
list is B. It is really syntactic sugar for [$a|B].

- A++"b" tries to match "b" against the end of a string which is impossible.


2009/4/29 Kevin <q2h46uw02@REDACTED>

> Does this behavior make sense to somebody or is this sugar tasting sour?
> 25> "a"++B = "ab".
> "ab"
> 26> A++"b" = "ab".
> * 1: illegal pattern
> I was just looking for an erlangy way to chomp the end of strings, like
> NewLine ++ "\r\n" = Line
> _______________________________________________
> 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/20090429/dd692dff/attachment.htm>

More information about the erlang-questions mailing list