Hi UiPath Team,
I am facing an issue for Extracting the String.
The string is as follows
Return - RDC 01.01 - CAPA Originator
Return - QDV 01.01 - Deviation/CAPA Initiator (US)
ADD - CCC 70.01 - Core Change Control View Only (Legacy)
4)ADD - CQA 02.02 - Reg Intel-Assessor
MODIFY - ITC 70.01 - ITCC View Only (Legacy) (US)
The strings I am able to fetch is look like above.
Among this strings I want the Value only after “-” and before “()” only.
Means my output should be look like below
1)RDC 01.01 - CAPA Originator
2) QDV 01.01 - Deviation/CAPA Initiator
3) CCC 70.01 - Core Change Control View Only (Legacy)
4) CQA 02.02 - Reg Intel-Assessor
5) ITC 70.01 - ITCC View Only (Legacy)
This are the possible outputs which we need to Extract from the above Strings
kindly help me on this issue to Match the Regex for all the cases.
Thanks
Sreenivasa
srinusoft37:
Return - RDC 01.01 - CAPA Originator
Return - QDV 01.01 - Deviation/CAPA Initiator (US)
ADD - CCC 70.01 - Core Change Control View Only (Legacy)
4)ADD - CQA 02.02 - Reg Intel-Assessor
MODIFY - ITC 70.01 - ITCC View Only (Legacy) (US)
Hello Try using below regex
(?<=\-)(.*?)(?=$|\(.*\))
adiijaiin
(Aditya Jain)
May 23, 2023, 8:08am
3
Hi @srinusoft37
Assuming that they are in separate lines,
here strData had 1. Return - RDC 01.01 - CAPA Originator
You can simply use strdata.Split({“-”},2,StringSplitOptions.None)(1).Trim
which will return
Thanks and Happy Automation!
1 Like
srinusoft37:
Return - RDC 01.01 - CAPA Originator
Return - QDV 01.01 - Deviation/CAPA Initiator (US)
ADD - CCC 70.01 - Core Change Control View Only (Legacy)
4)ADD - CQA 02.02 - Reg Intel-Assessor
MODIFY - ITC 70.01 - ITCC View Only (Legacy) (US)
Thanks for quick reply
This is helping me to extract the value after - and before the (), but in few cases we need to extract the () values also
for the 3rd and 5th line I need the data along with the (Legacy) as well
so the pattren should be like
CCC 70.01 - Core Change Control View Only (Legacy)
ITC 70.01 - ITCC View Only (Legacy)
Thanks
Sreenivasa
What is the logic here to decide whether you want to extract this bracket information or not? Or Is it only when we have legacy word we need to extract?. Can you clarify this information?
We have to remove the string if that contains the (US) in the “()” the remaining should be Extracted.
Thanks
Sreenivasa
ppr
(Peter)
May 23, 2023, 8:23am
7
As simple one
We would later trim the match results
This CheatSheet introduces the basic use of regex functions. With further examples also special cases are presented.
Introduction
From the namespace System.Text.RegularExpressions following methods are offered:
Regex.Match
Regex.Matches
Regex.isMatch
Regex.Replace
Regex.Split
A simple usage for example would look like this:
[grafik]
Recommendation:
add System.Text.RegularExpressions to the imports:
[grafik]
it allows to use the shortened statement, as the namespace part can be ommited…
Thanks for the quick reply.
Yes agree , but not sure which strings contains the value (US). So its could be better if we can remove the values which is (US) along with the string.
Thanks
Sreenivasa
Thanks for the solution.
Can we add the some other unwanted values if require, Like we did we remove the (US) like that can we remove some other values as well
Thanks
Sreenivasa
We can add value, but that is exactly the reason I was asking how dynamic it can be. Could you provide more example of string which has different format?
1 Like
Hi PPR,
Here is another example which is causing an issue, Like we remove the (US) we need to remove the (Intl) as well. please see the below string
Add - QA 02.01 - AA Originator QC Associate (Intl)
In this also we need to remove the (Intl)
Could you help me on this. in future like if any new unwanted data added I will edit for multiple strings as well.
Thanks
Sreenivasa
ppr
(Peter)
May 23, 2023, 4:45pm
13
Just create a new topic and let us know all different variations as also suggested by
As suggested by Dilip This 2 are the scenarios I have
remove the (US)
Remove the (Intl)
Thanks
Sreenivasa
system
(system)
Closed
May 26, 2023, 5:22pm
15
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.