regexp
Tanja Godau
eedtag@REDACTED
Thu Aug 15 10:39:56 CEST 2002
Hi,
I've been using the regexp module to match various strings and parts of strings.
I would like to know how can I extract one or more variables from my match.
For example:
I receive a string "\000\005\abc"
I identify the string due to the leading three zeros, but I need to extract
the number "5" and the letters "abc" from the string.
I've used regexp's with Perl and there I would bracket the parts I need and be
able to use them later as the variables $1, $2, etc. I'd like to know how to
do the same thing with Erlang.
Something like this:
String = "\000\005\abc",
case regexp:match(String, "\\000.*\\00(.*)\\00(.*)") of
{match,S,L} ->
io:format("Number: ~p~n",[$1]), % this prints "Number: 5"
io:format("Text: ~p~n",[$2]); % this prints "Text: abc"
nomatch ->
...
Question: How can I match a string and extract the variables I need in Erlang?
Thankyou
Tanja Godau
More information about the erlang-questions
mailing list