Extracted portions of a text

Hi ,

I have the following in a string variable. From this I need to extract only product name, model name and report number. Please let me know the easiest and best method to do it either through string manipulations or regex or any other .

String:
V V BiCTC TephnologiyiLitd. , R5port no.: BCTC-625987:
FCC.) Part 159 Teet Heport
FCC ID: :94lLi7933L3B/6ELD
I Product Name: I 22-Inch Wheels I
ITrademark: I (fonnnvnu) I
I Model Name : I M00653 I
Prepared For : Cordovan Limited
Address 1 6 Ludington Center, Sarasota, Florida
Prepared By : BCTC Technology Ltd.
Address : 96029 Fulton Junction, Richmond, Virginia, USA
ITest Date: I 16 Jan 2019 - 18 Jan 2019 I
I Date of Report : I 19 Jan 2019 I
I Report No.: I BCTC-625987 I

@Purnima_Sambasivan
You can start with RegeE and the Match Activity. Have a look here:

(?<=I Product Name: ).*

grafik

replacing the yellow marked portion with the other Key Words should grap the other parts.

Let us know your feedback

3 Likes

Hi @Purnima_Sambasivan
To expand upon @ppr’s post and predict your response use these solutions below which won’t capture the “I” at the start and end. Also the “:” moves around.

Take a look at these regex solutions:
(?<=Product Name: )I (.*) I

(?<=Model Name : )I (.*) I

(?<=Report No\.: )I (.*) I

Use these in 3 Matches activity and use each Output variable in an Assign activity like this:
ProductName = OUTPUTVARIABLE(0).groups(1).tostring
ModelName = OUTPUTVARIABLE(0).groups(1).tostring
ReportNumber = OUTPUTVARIABLE(0).groups(1).tostring

Replace capitals with each Matches output variable.

Thank you so much. Cant we use just ONE matches activity and add all the 3 patterns. What are settings to use? - Literal , advanced …any other? Sorry for these questions but i am a bit new to regex, tried reading through not getting an apt solution.

and also (?<=Product Name: )I (.*) I is also extracting along with ‘|’ symbol

when i give ProductName = OUTPUTVARIABLE(0).groups(1).tostring
ModelName = OUTPUTVARIABLE(0).groups(1).tostring
ReportNumber = OUTPUTVARIABLE(0).groups(1).tostring
this says , the enum varaible is not initialised

Hello

You could use one Matches activity but would need to change the Regex pattern. To keep it simple I would use 3.

The default settings in UiPath for the Matches activity will be fine.

Make sure you have setup your variables correctly. The easiest thing to do is go the output field and hit “Ctrl + K”

i got the answer… kept 3 matches and works great . I had to use a FOR EACH for the list which i feel is not needed since there is only 1 Item in the list. All the variables are declared with CTRL+K . But this didnt work
OUTPUTVARIABLE(0).groups(1).tostring.

Still figuring out that part. Thanks a ton Mr.Steven.

Instead of a regex how do we do this with String Manipulations? Extracting the same details?

Thank you so much @ppr`. Instead of Regex how do we do it using String Manipulations technique?