Need regex/String Manipulation for Phone Name, color & Storage

Samsung Galaxy On8 (Gold, 3GB RAM, 16GB Storage)
(Renewed) Samsung Galaxy M01 Core (Black, 1GB RAM, 16GB Storage) Without Offer
Samsung Galaxy J7 2016 Edition SM-J710F (Gold, 16GB)
(Renewed) Samsung Galaxy J5 6 (Gold, 16 GB)
(Renewed) Samsung Galaxy On8 SM-J710FN (Gold, 16GB)
Samsung Galaxy J2 Pro SM-J210FZSGINS (Silver)
Samsung Galaxy J7 New 2016 Edition (White, 16GB)
Samsung Galaxy E5 (Brown)
Samsung Galaxy J5 6 (Gold, 16 GB)
(Renewed) Samsung Galaxy A7 2016 SM-A710FZDFINS (Gold, 16GB)
Samsung Galaxy J5 (New 2016 edition) (Black, 16 GB)
(Renewed) Samsung Galaxy On8 SM-J710FN (White, 16GB)
(Renewed) Samsung Galaxy M10 (Ocean Blue, 2+16GB)
(Renewed) Samsung Galaxy A2 Core (Blue, 1GB RAM, 16GB Storage) Without Offer
(Renewed) Samsung Galaxy J7 SM-J700F (Gold, 16GB)
Samsung Galaxy J5 2016 (White, 16GB)

@Manju_Reddy_Kanughula

Please try this

Name - System.Text.RegularExpressions.Regex.Matches(str,".+(?=\()")

Color - System.Text.RegularExpressions.Regex.Matches(str,"(?<=\()[A-Za-z]*(?=,)")

Storage - System.Text.RegularExpressions.Regex.Matches(str,"(?<=,).*(?=\))")

These will gvie you all matches use loop to loop through each match type argument in loop will be System.Text.RegularExpressions.Regex.Match and currentitem.value will give the value

Cheers

HI @Manju_Reddy_Kanughula

Checkout this expression

Name

System.Text.RegularExpressions.Regex.Match(InputString,"^.*(?=\()").Tostring.replace("(Renewed)","").Trim

Colour

System.Text.RegularExpressions.Regex.Match(InputString,"(?<=\s\()\S+(?=\,)").Tostring

Storage

System.Text.RegularExpressions.Regex.Match(InputString,"(?<=\,).*GB(?=\))|(?<=\,\s)\S+(?=\sStorage)").Tostring

Regards
Sudharsan

Hi @Manju_Reddy_Kanughula

Check this expression for Name

System.Text.RegularExpressions.Regex.Match(YourString,"^(.+?)(?= \()").Tostring

Check this foe Color and Storage

System.Text.RegularExpressions.Regex.Match(YourString,"\((\w+), \d+GB RAM, (\d+GB) Storage\)").Groups(1)
System.Text.RegularExpressions.Regex.Match(YourString,"\((\w+), \d+GB RAM, (\d+GB) Storage\)").Groups(2)

Regards
Gokul

Hi @Manju_Reddy_Kanughula ,

Could you maybe try with the below regex Expression :

(.*)(?=\()(.*)(?=\()\((.*?)(?=,|\))(.*(?=,),(.*)(?=\)))?

Preparing the Required Columns Datatable using Build Datatable activity and then use the Regex Expression in Matches Activity to get the collection of the Match data and then add the required groups into the Output Datatable using Add Data Row activity.
image

Visuals :

Let us know if you are not able to get the required output.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.