2016-04-07 4 views
0

J'essaie de trouver la chaîne "Standard Premium est" dans la chaîne "En 2015, la partie Standard Standard B mensuel est 104,90 $" mais je suis incapable de le faire en cochon.Cochon Motif correspondant

Je suis en train avec le regex

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

mais quand je suis en train de trouver simplement 'Premium' avec le ci-dessous regex cela fonctionne:

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

Répondre

0

Tu ne peux pas utiliser le EqualsIgnoreCase() La fonction EqualsIgnoreCase() permet de comparer deux chaînes et de vérifier si elles sont égales. Si les deux sont égaux, cette fonction renvoie la valeur booléenne true sinon elle renvoie la valeur false.

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

Ou vous pouvez essayer la fonction regex REGEX_EXTRACT ou REGEX_EXTRACT_ALL.

J'ai essayé quelque chose avec REGEX ..check si cela fonctionne pour vous ici %s serait le texte que vous voulez faire correspondre

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

Cette déclaration ajoutera un autre champ où il aura un match et que le terrain est (). Donc, pour obtenir les données correspondantes, nous allons lancer un filtre.

filtered = FILTER b BY $2 is not null;