[erlang-questions] gregexp module question

Balu Balasubramanian <>
Tue Jan 29 09:27:47 CET 2008


Hi,

I wanto match 0 or multiple instances of any character INCLUDING the new line character \n.

1) I do not like (.|\n)* because  it messes up groupings, as i n

51> init:script_id().
{"OTP  APN 181 01","R11B"}
52> gregexp:groups(S,"^HTTP\\(.|\n\\)*\\(Server:\\(.*\\)\\)?\r\n").
{match,["h","j","g","\r","\n","g","h","o"," Apache","Server: Apache"]}
53> S.
"HTTPhjg\r\nghoServer: Apache\r\n"
54>


2) There seems to be no option to tell the (g)regexp module to modify the meaning of "." to include "\n".

3) stuff like [\s\S]*  or [.\n]*do not seem to work.
55> gregexp:groups(S,"^HTTP[\s\S]*\\(Server:\\(.*\\)\\)?\r\n").
nomatch
56> gregexp:groups(S,"^HTTP[.\n]*\\(Server:\\(.*\\)\\)?\r\n").
nomatch
57>

May be I am doing something wrong?

Is there any other way of doing this ?

Thanks for any help.

Balu


_________________________________________________________________
Shed those extra pounds with MSN and The Biggest Loser!
http://biggestloser.msn.com/


More information about the erlang-questions mailing list