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