on 07-04-2016 1:48 PM
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:-
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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??
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
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.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.