Erlang中的字符串正则表达式匹配 [英] String regex matching in Erlang

查看:460
本文介绍了Erlang中的字符串正则表达式匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何在Erlang中进行正则表达式匹配?



我所知道的是:
f( AAPL ++ Inputstring)-> true。 / p>

我需要匹配
的行 AAPL,2010年5月7日15:58,21.34,21.36,21.34,21.35,525064\n



在Perl正则表达式中:^ AAPL **(或类似名称)



在Erlang中?

解决方案

使用 re 模块,例如:

  ... 
字符串= AAPL,2010年5月7日15:58,21.34,21.36,21.34,21.35,525064\n,
RegExp = ^ AAPL,*,
例re:run(String,RegExp)
{match,Captured}-> ...;
nomatch-> ...
结尾,
...


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?

解决方案

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,
...

这篇关于Erlang中的字符串正则表达式匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆