How to extract RAM, ROM, Screen Size, Camera , product name from below 2 string

Oppo F23 5G (Bold Gold, 8GB RAM, 256GB Storage) | 5000 mAh Battery with 67W SUPERVOOC Charger | 64MP Rear Triple AI Camera with Microlens | 6.72" FHD+ 120Hz Display | with Offers

Nothing Phone 1 5G White 8GB RAM 256GB ROM | 6.55 inch 120Hz OLED Display | 50MP + 50MP Rear | 16MP Front Camera | Glyph Interface | Qualcomn Snapdragon 778G+ Processor

  1. Oppo F23 5G (Bold Gold, 8GB RAM, 256GB Storage):
  • RAM: Use the pattern \d+GB RAM to extract the RAM information.
  • ROM: Use the pattern \d+GB Storage to extract the ROM information.
  • Screen Size: Use the pattern \d+\.\d+" to extract the screen size.
  • Camera: Use the pattern \d+MP Rear to extract the camera information.
  • Product Name: Use the pattern ^[^\(]+ to extract the product name.
  1. Nothing Phone 1 5G White 8GB RAM 256GB ROM:
  • RAM: Use the pattern \d+GB RAM to extract the RAM information.
  • ROM: Use the pattern \d+GB ROM to extract the ROM information.
  • Screen Size: Use the pattern \d+\.\d+ inch to extract the screen size.
  • Camera: Use the pattern \d+MP \+ \d+MP Rear to extract the camera information.
  • Product Name: Use the pattern ^[^\d]+ to extract the product name.

[A-Za-z0-9\s+."](?= Display) for Display
[A-Za-z0-9]
(?= RAM) For Ram
[A-Za-z0-9](?= Storage)
rear camera [A-Z0-9\s+]
(?= Rear)
Product name .(?<= 5G)
FOR SECOND STRING
[A-Za-z0-9\s+."]
(?= Display) for Display
[A-Za-z0-9](?= RAM) fOr Ram
[A-Za-z0-9]
(?= ROM)
rear camera [A-Z0-9\s+](?= Rear)|rear camera [A-Z0-9\s+](?= Front)
Product name .*(?<= 5G)

1 Like

will it work for the format

should I enter each pattern in separate variable?

It should be work you can test it on β€œRegex101”

You can use system.text.regularexpression.regex.matches(yourstring," [A-Za-z0-9\s+.β€œ](?= Display)| [A-Za-z0-9] (?= RAM)| [A-Za-z0-9](?= Storage)| [A-Z0-9\s+] (?= Rear)”)
Seperate each with symbol = | after each format

using which activity?

you can write in assign and the
variable created datatype should be matchcollection

Hi @babita

For extracting
RAM -

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,β€œ(\d+\w+(?=\sRAM))”)

ROM -

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,β€œ((?<=RAM,*\s)\d+GB)”)

Screen Size -

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,β€œ(\d+.\d+)”)

Camera -

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,β€œ((?<=|\s)(\d+MP\s\w*\s\w*\s\w*\s\w*\s\w*\s\w*)|(\d+MP\s+\s\d+MP\s\w+)(?=\s|))”)

Product Name -

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,β€œ(\w+\s\w*\d*\s*\w*\d*(?=\s5G))”)

Hope it helps!!