[erlang-questions] parsing text

Wes James comptekki@REDACTED
Sat May 1 15:59:09 CEST 2010


On Sat, May 1, 2010 at 4:03 AM, Joe Armstrong <erlang@REDACTED> wrote:
> I think I'd have pretended that the input string were Erlang tokens.
> I'd then use the Erlang tokeniser and pattern match the output, thusly:
>
> 1 > X="<B>Page Counter</B></TD><TD>4880</TD></TR>".
> ..
> 2 > hd([I || {integer,_,I} <- element(2, erl_scan:string(X))]).
> 4880
>
> erl_scan:string is your friend :-)
>
> /Joe

Thx.  Joe.  I'm a sys admin at a university and everyone's help here
will make it easier for me learn how to parse the input of a brother
printer config page that has the page count.  Yesterday I went through
some mnesia tutorials about creating tables and putting data in.  I
plan on using erlang:date() to put the count in a page_count record.

thx,

-wes


More information about the erlang-questions mailing list