cancel
Showing results for 
Search instead for 
Did you mean: 

Problems faced in the rule using match pattern(or match regex)?

former_member188628
Participant
0 Kudos

Hi All

      I have got input data, where the names of the people have "Mr,Mrs,Ms" as initial. I got to use this info to divide the data gender wise.I tried using match_pattern.However, its displaying partial results:-

 

If I try using the match_regex in place of match_pattern in the above case instead, i am getting different output:-

   

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

match pattern and match regex functionality are different.

if you use, match pattern, use below line in line 17, as 'or' is an inbuilt keyword

IF (match_pattern($CustName, 'Mrs.*') or match_pattern($CustName, 'Ms.*')) RETURN TRUE;

if you go for match regex use below code,

BEGIN

IF (match_regex($CustName, 'Mr.[a-zA-Z ]*')) RETURN TRUE; ELSE RETURN FALSE;

END

ELSE IF ($Gender='Female')

BEGIN

IF (match_regex($CustName, 'Mrs.[a-zA-Z ]*') or match_regex($CustName, 'Ms.[a-zA-Z ]*')) RETURN TRUE;

ELSE RETURN FALSE;

END

BR

Nethaji Guru

former_member188628
Participant
0 Kudos

Hi Nethaji

   Thanks a lot for the reply, let me try and get back on this

Regards

former_member188628
Participant
0 Kudos

Hi

  I do have little doubts over the match regex expression:-

If i use the first case as highlighted, Its displaying incorrect output!!Why?Mr.*vs Mrs.*

However in the case 2:[a-zA-Z] also includes 's' creating Mrs or Mr.s,I mean why working there,If i exclude Mrs.* and opt for Ms.* alone ,things are perfectly working fine??

Former Member
0 Kudos

Hi Moumita,

Please find the below simple rule created without using any match_pattern or match_regex ..

begin

if(($gender='Male' and $customer like 'Mr.%') or ($gender='Female' and ($customer like 'Mrs.%' or $customer like 'Ms.%')))

return true;

else

return false;

end

Try this and please let me know if it is resolved your issue.

Thanks,

Hema

Former Member
0 Kudos

Probably you need to understand the difference between match_regex and match_pattern.

Regex will function like repetitive patterns of string. you can refer to the regular expression so that you will become expert in forming the regex.

when you add Mr.*

* will allow zero or more occurrence of preceding alphabets.

. will look for a single character.

as you added * it passes all entries with Mr

try a test value gender like 'Male' and name like 'Ms.'

while match pattern will function as like function in SQL script.

Answers (0)