2016-04-07 82 views
0

我试图在字符串中找到字符串“标准溢价是”2015年B部分标准溢价是$ 104.90“但我无法在猪身上这样做。猪模式匹配

我用正则表达式

`PlanServiceEng = FILTER PlanService BY language == 'English' and contractid !='' and planid !='' and segmentid !='' and benefit !='' and (benefit MATCHES '.*Standard Premium is.*');` 

努力,但是当我试图找到刚刚“高级”与 下面的正则表达式它的工作原理:

PlanServiceEng = FILTER PlanService BY language == 'English' and contractid !='' and planid !='' and segmentid !='' and benefit !='' and (benefit matches '.*Premium.*'); 

回答

0

不能使用EqualsIgnoreCase()函数

EqualsIgnoreCase()函数用于比较两个字符串并验证它们是否相等。如果两者相等,则此函数返回布尔值true否则返回值false。

PlanServiceEng = FOREACH PlanService GENERATE (language,benefit), EqualsIgnoreCase(benefit, 'Standard Premium is'); 

或者您可以尝试正则表达式函数REGEX_EXTRACT或REGEX_EXTRACT_ALL。

我尝试一些与REGEX ..check如果这对你的作品 这里%s将要匹配

b = FOREACH a GENERATE $0,$1,REGEX_EXTRACT_ALL($1,'.*%s.*') ; 

这条语句将添加一个字段,其中将有一个匹配的文本和字段()。所以为了获得匹配的数据,我们将运行一个过滤器。

filtered = FILTER b BY $2 is not null;