Extract Memory device name and color

Hi All,

i have a String “Iphone XR 128GB Blue - IPXR128BLU (Out of Stock) | Iphone XR 128GB Blue - IPXR128BLU (Out of Stock)” and from this i want to extract devicename-IPXR, Memory-18 and Color"BLU".

String can also be like : “APPLE IPAD 32GB GREY refurb -IPD5L32GRYRFB”
and from this also device name,memory and color needs to be extracted

How can it be done?

Hi Somya,

You need to define good rules for the extraction to work.

First you need to locate the code that contains those parts “IPXR128BLU”. Is it always the first word after the “-”? If yes, that’s your rule. Then, having the code, I guess it would be easy to find the memory, as this is usually one of the values 16, 32, 64, 128, 256 or 512. Then, the first part should be considered the device name and whatever is after the color?

Regards
Silviu

1 Like

@somya177

Use this regex : (?<=(.+)(-)(\s)?)[\w\d]+

The above regex will return the values - IPXR128BLU, IPXR128BLU and IPD5L32GRYRFB

and you have to use substring to get Device name, Memory and Color

1 Like