Labels

2017 absence absence management Account accounting AIM aliases AME and API application application utilities lookups approval assignments ATO Australia Bank bi publisher budget business business groups CAGR candidates cartisian product case CEMLI Center Stage channels Classification competency concurrent Configuration configuration profile constants contextualization conversion correction cost costing coverage area customization data database date DateTracked deductions define design develop DFF diagnostics document earnings ebs EIT Element employee enhancements erp excel expression extension failure Fastformula FBT Flexfield FND fndload foreign key forms Formula fringe benefit FRM-40654 from FTE Functions fund fusion GL global transfer grade help hierarchy HR HRMS human resource management system implementation income information interfaces internet interview job join key flexfield KFF KPI language learning leave legal employer legislation links lists localization location management New Year obia obiee OLF onboarding oracle oracle applications oracle descriptive flex field oracle descriptive flexfield oracle ebs oracle erp oracle fusion HCM oracle hrms oracle hrms interview questions oracle hrms modules oracle hrms modules list oracle hrms organization oracle hrms table oracle hrms tables oracle hrms tutorial oracle irecruitment oracle legal entities oracle lookups oracle organization hierarchy oracle payroll oracle payroll interview questions oracle payroll tables oracle self service order by Organization organization type otbi package package body package specification patch payg Payment payroll people group perform person personalisation phase pl/sql position primary key process profile programs project qualifier Query question questions Recruiting Center Recruitment regex regular expression reporting tool reports requests requirement requisition resume retropay RICE salary schema security profile select SIT smartorg sql statutory stores STP Super Superannuation system systems Table Taleo taleo 15B Taleo Recruitment tax termination test testing trunc update user group user management user type value set variables View Views Web ADI webadi where work relationship

Thursday, 13 July 2017

Using Regular Expression function (Regex) in SQL - Part II


  • Validate a string for lower case alphabets only

select case when regexp_like('Mohit' ,'^([[:lower:]]{3,12})$') then 'Match Found' else 'No Match Found' end as output from dual;
Output: No Match Found
If we change the input to “mohit”, we get a match. In the above example we tried to check if the source string contains only lower case alphabets with a string length varying from minimum of 3 to max of 12.
The pattern is similar as above but {3,12}. {3,12} specifies at least 3 alphabets but not more than 12

  • Case Sensitive Search


select case when regexp_like('United States OF America' ,'of', 'c') then 'Match Found' else 'No Match Found' end as output from dual;

Output: No Match Found
“c” stands for case sensitive
In the above example we tried to search for the pattern “of” exactly matching the case and hence we didn’t find a match.
Let’s now try a search for “of” in the source string irrespective of the case in the below example:

select case when regexp_like('United States OF America' ,'of', 'i') then 'Match Found' else 'No Match Found' end as output from dual;

Output: Match Found
“i” stands for case insensitive

  • Match nth character

select case when regexp_like('mo*it' ,'^..[^[:alnum:]]') then 'Match Found' else 'No Match Found' end as output from dual;

Output: Match Found
In the above example we tried to search for a special character at the 3rd position of the input string “mo*it”

Let’s now try to understand the pattern '^..[^[:alnum:]]'
^ marks the start of the string
. a dot signifies any character (.. 2 dots specify any two characters)
[^[:alnum:]] Non alpha-numeric characters (^ inside brackets specifies negation)
Note: The $ is missing in the pattern. It’s because we are not concerned beyond the 3rd character and hence we need not mark the end of the string. (..[^[:alnum:]]$ would mean any two characters followed by a special character and no characters beyond the special character)

No comments:

Post a Comment