cancel
Showing results for 
Search instead for 
Did you mean: 

Syntax for matching the string patterns in Match Regex() in information Steward?

former_member188628
Participant
0 Kudos

Hi All

     I need to check whether the given address is valid only if contains the strings like "Ave", "St", "Blvd" ,"Rd" . I tried using the match Regex()               function with the following syntax, However its not yielding the desired results. Following is part of my "Address filed"::-

The Regex used in Information Steward :-

BEGIN

RETURN match_regex($Address, '"Ave","St","Rd","Blvd","Dr"', 'CASE_INSENSITIVE');

END

The test results (unexpected):-

Accepted Solutions (1)

Accepted Solutions (1)

krishnamohan_corp9
Participant
0 Kudos

Hi,

please try the below rule.

begin

if(upper($address) in ('ave', 'st','rd','blvd','dr'))

return true;

else

return false;

end

or u can  use this one also

begin

if(upper($address) like ('%ave%', '%st%','%rd%','%blvd%','%dr%'))

return true;

else

return false;

end

the above rules will be moved to passed data set. If u want to move those records which r having those above keywords change the code to:

return false;

else

return true;

end

mark it as helpful/correct answer if it is useful to u For yesterday and todays answer 🙂

regards

krishna

former_member188628
Participant
0 Kudos

Hi

   The same is not achievable by MatchRegex() or MatchPattern()???

krishnamohan_corp9
Participant
0 Kudos

Those are used for identifying special charecters in the string the name itself says match regular expression.

just check user guide for more info.

former_member188628
Participant
0 Kudos

Hi

   I tried with the "In" syntax, however there is no change in the test results,Its still the same as with the previous MatchRegex() results

Regards

former_member187605
Active Contributor
0 Kudos

The "in" example is not correct, it will only return true, if the input matches exactly one of the specified values.

Try with "ave" for $Address.

former_member188628
Participant
0 Kudos

Hi

     The solution described above(using In) isn't providing the desired results . The In  example is returning all the values either all false or all True(if we alter the positions of true and false).But If i try with Like is ending up with syntax errors:-

I was wondering about the alternative solution for this, but like should actually workNeed Help

former_member187605
Active Contributor
0 Kudos

Actually, his other exampkle with like is not correct either. Not at all! Why do you mark that as a helpful answer??? It's not helpful at all, just misleading, I am sorry.

The "in" operator has multiple operands at right-hand side.

The "like" operator suppports a single right-hand operand only.

And the upper function turns everything into uppercase,too. That will never lead to a match with lower case strings.

So what you can try is:

return lower($address) like '%ave%' or lower($address) like '%st%' or lower($address) like '%rd%' or lower($address) like '%blvd%' or lower($address) like '%dr%';

But beware! This is not a good use case for Information Steward. Values like 'First Orchard Square' will also Pass.

former_member188628
Participant
0 Kudos

Hi Dirk

     The like is working, even for 'First Orchard Square', I just removed Lower() before each of the string, and Capitalized the first letter,like Rd, Ave:-

However the same (First Orchard Square) is not working with regex, as shown in the response from Abdul,I wonder Why?

former_member187605
Active Contributor
0 Kudos

It's the last parameter. It says case_INsensitive, doesn't it?

former_member188628
Participant
0 Kudos

Hi

   I am just a beginner, and I am seriously thankful and grateful towards the spirit of helping and contributing towards a problem,to such an extent by experienced programmers,consultants at any point of time.Opening up towards various sources of information is a great help towards the process of learning.

                  In this case for example,I tried a way to use the regex and got another way to use In and Like(although might be with syntax errors initially as posted),which again triggered me towards the search of various possible solutions, finally satisfied with Like syntax(Solution by Dirk).

This may not be of much help for experienced people, but for a novice like me found it helpful, as an add on information and alternative ways towards a solution(hence marked)

But Dirk's and his posts and similar help by other consultants and experienced people in these forums, are just great and awesome

  Thanks a lot to all of you. Thanks a lot Dirk

Regards

former_member188628
Participant
0 Kudos

Hi Dirk

   Wo!! Its working now,finally problem solvedThanks a lot

Thanks

Regards

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Moumita

You might want to try the syntax below. It does however introduce false positives (see highlighted example) so you going to have to refine the regex:

Regards

Abdul

*Edit: Dirk sums it up well in his post 🙂