Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String regex matching in Erlang

How would I do regex matching in Erlang?

All I know is this: f("AAPL" ++ Inputstring) -> true.

The lines that I need to match "AAPL,07-May-2010 15:58,21.34,21.36,21.34,21.35,525064\n"

In Perl regex: ^AAPL,* (or something similar)

In Erlang?

like image 738
Lydon Ch Avatar asked May 13 '10 15:05

Lydon Ch


1 Answers

Use the re module, e.g.:

...
String = "AAPL,07-May-2010 15:58,21.34,21.36,21.34,21.35,525064\n",
RegExp = "^AAPL,*",
case re:run(String, RegExp) of
  {match, Captured} -> ... ;
  nomatch -> ...
end,
...
like image 154
3lectrologos Avatar answered Oct 17 '22 01:10

3lectrologos