根据单词过滤字符串 [英] Filter a string on the basis of a word

查看:24
本文介绍了根据单词过滤字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一份养猪工作,我需要通过在其中查找单词来过滤数据,

I have a pig job where in I need to filter the data by finding a word in it,

这是片段

A = LOAD '/home/user/filename' USING PigStorage(',');
B = FOREACH A GENERATE $27,$38;
C = FILTER B BY ( $1 ==  '*Word*');
STORE C INTO '/home/user/out1' USING PigStorage();

错误在第 3 行,同时查找 C,我也试过使用

The error is in the 3rd line while finding C, I have also tried using

C = FILTER B BY $1 MATCHES '*WORD*'  

还有

C = FILTER B BY $1 MATCHES '\\w+WORD\\w+'  

推荐答案

MATCHES 使用正则表达式.你应该用 ... MATCHES '.*WORD.*' 代替.

MATCHES uses regular expressions. You should do ... MATCHES '.*WORD.*' instead.

这些是此处找到apache"一词的示例'.

These is an example here finding the word 'apache'.

这篇关于根据单词过滤字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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