cancel
Showing results for 
Search instead for 
Did you mean: 

How to Split using Regex expression

pranil2k2
Contributor

Hi,

I need some help on spliting the user name on basis of Regex expression.My user Name is an combination of mutliple users and i cant use comma to split them. so, i tried regular expression and which is working good on DB level and planned to implement same in Snaplogic, but it is not working. Please some one can help me here.
image

8 REPLIES 8

RogerSramkoski
Employee
Employee

Are you able to share an example name, or confirm if something like JohnBobSarahBill is a good example? If so, and if this could be any combination of names, what are you able to split on? Is each name always the same length?

pranil2k2
Contributor

Hi,

The best example is below, it have three names separated by comma, so I thought of using some logic as
“regexp_substr(dossier_lead, ‘[[:alnum:] .()-]+, [[:alnum:] .()-]+’,1, level,‘i’)” it is working in oracle but it is hanging, so i thought of trying same logic in snaplogic.

Example: john, maria,lisa, awari,Arun, john(TCS)

Thank you for the additional information. I believe there was a typo in the initial post indicating that you could not use commas. If your JSON was something like “names” : “john, maria,lisa, awari,Arun, john(TCS)” you could use the expression $names.split(‘,’) which will result in a “names” array. If you want to remove the white space you could use $names.replaceAll(’ ‘,’‘).split(’,').

Screenshot of split only:
image
Screenshot of expression with replaceAll and split:
image

Hi,
I tried above solution, but i am getting output as below

image .

but the excepted output will be combination of first name and last name (john, maria).

Any advice. Thanks