[erlang-questions] String handling & regexp
Edwin Fine
erlang-questions_efine@REDACTED
Sun Sep 14 21:18:51 CEST 2008
Well, it's in R12B-3, and here's part of my session:
14> {ok, RE} = re:compile("^ *(\\d{4})/(\\d{1,2})/(\\d{1,2})
*$").
{ok,{re_pattern,3,0,
<<69,82,67,80,103,0,0,0,16,0,0,0,5,0,0,0,3,0,0,0,0,0,47,
...>>}}
15> re:run("2008/09/14", RE, [{capture, all_but_first,
list}]).
{match,["2008","09","14"]}
All I did from the command line was type in erl, nothing else.
HTH
Edwin
On Sun, Sep 14, 2008 at 2:01 PM, Olivier Pernet <o.pernet@REDACTED> wrote:
> Neat! But...
> I'm running R12-4, and looking at the
> /usr/local/lib/erlang/releases/R12B/start.script I can see the re
> module. But it doesn't seem to be accessible from the erl prompt, even
> though application:which_applications() lists stdlib as started. I'm
> confused...
>
> Olivier Pernet
>
> We are the knights who say
> echo '16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D4D465452snlbxq'|dc
>
>
>
> On Sun, Sep 14, 2008 at 6:34 PM, Steve Vinoski <vinoski@REDACTED> wrote:
> > re is in R12B-4, the latest release, so it's already included.
> >
> > On 9/14/08, Olivier Pernet <o.pernet@REDACTED> wrote:
> >> Thanks, re looks just about right. I was hoping for a standard library
> >> solution at first... How fast do the OTP libraries evolve ? Any chance
> >> of this being included someday ?
> >>
> >> Olivier
> >>
> >> On Sun, Sep 14, 2008 at 9:42 AM, Edwin Fine
> >> <erlang-questions_efine@REDACTED> wrote:
> >> > Take a look at the re module. It has exactly what you need.
> >> >
> >> > On Sun, Sep 14, 2008 at 3:04 AM, Olivier Pernet <o.pernet@REDACTED>
> wrote:
> >> >>
> >> >> Hi all,
> >> >>
> >> >> I'm new to Erlang, and trying not to reinvent the wheel to do some
> >> >> basic string processing.
> >> >> I'm reading a line that has a room name and a message, separated by
> >> >> one (or more) whitespace characters, and terminated by <crlf>.
> >> >> Is there a way to tell regexp:split() to please give me back the
> >> >> groups matched by the regexp ?
> >> >> Here's my first attempt :
> >> >> regexp:split(" \t \t room \t hello world \r\n", "[
> >> >> \t]*([^\s\t\r\n]+)[ \t]+([^\r\n]*)\r\n").
> >> >> I'd like to get back something like ["room", "hello world "] with
> this
> >> >> example.
> >> >>
> >> >> Thanks for your help,
> >> >> Olivier Pernet
> >> >>
> >> >> We are the knights who say
> >> >> echo '16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D4D465452snlbxq'|dc
> >> >> _______________________________________________
> >> >> erlang-questions mailing list
> >> >> erlang-questions@REDACTED
> >> >> http://www.erlang.org/mailman/listinfo/erlang-questions
> >> >>
> >> >
> >> >
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://www.erlang.org/mailman/listinfo/erlang-questions
> >>
> >
> _______________________________________________
> 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/20080914/857ec586/attachment.htm>
More information about the erlang-questions
mailing list