Reddy_1
(Berdy)
June 1, 2021, 5:42am
1
I have a question?
I have a variable that contains a value like this
“Marsh-India-Hyderabad 28/00/00, KPHB, Hyderabad, Telangana, 500072, India”
“Aon ABC 55 11/22/33 Banjarahills Hyderabad Telangana 500081 India”
From the above value, I want value like
1.Marsh-India-Hyderabad
2.Aon ABC 55
Please help me.
Regards,
Reddy.
Yoichi
(Yoichi)
June 1, 2021, 5:46am
2
Hi,
Can you try the following?
System.Text.RegularExpressions.Regex.Match(yourString,".*?(?=\s28/00/00)").Value
Regards,
1 Like
Reddy_1
(Berdy)
June 1, 2021, 5:49am
3
But the Address also different each and every time.
Yoichi
(Yoichi)
June 1, 2021, 5:54am
4
Hi,
If string always has nn/nn/nn format (like 28/00/00 or 11/22/33), the following will work. Can you try this?
System.Text.RegularExpressions.Regex.Match(yourString,".*?(?=\s\d{2}/\d{2}/\d{2})").Value
Regards,
Reddy_1
(Berdy)
June 1, 2021, 6:03am
5
What if address contains like this?
Marsh-England-Maidstone 100 Kings Hill Avenue, West Malling, Maidstone, Kent, 111111, United Kingdom,Active
Yoichi
(Yoichi)
June 1, 2021, 6:10am
6
Hi,
We need to find some rule to extract target string.
If you can accept multiple steps, the following might fit for you.
If string contains nn/nn/nn, use the following expression.
System.Text.RegularExpressions.Regex.Match(yourString,".*?(?=\s\d{2}/\d{2}/\d{2})").Value
If not contains ( in case that result of 1 is empty), use the following, for example.
System.Text.RegularExpressions.Regex.Match(yourString,".*?(?=\s\d+)").Value
Regards,
Reddy_1
(Berdy)
June 1, 2021, 6:21am
7
Summary
Marsh-England-Edinburgh Northumberland Street, North East Lane, Edinburgh, EH3 6LN, United Kingdom, Active
For above value it is not working and one more thing at address part the value is dynamic for every time, sometimes it contais some format and some times it contains another format. It it dynamically changing
Yoichi
(Yoichi)
June 1, 2021, 6:24am
8
Hi,
As i mentioned, we need to find some rule to extract target string.
If we cannot find it ,it’s difficult to extract it using regex etc, I think.
Regards,
Try this regex expression
[\w\-\ ]+(?= \d{2}\/\d{2}\/\d{2})|(\w+\-\w+\-\w+)
Let me know where it fails.
Is it possible to get the value in a better format? Always look for ways to improve the process itself rather than just deal with bad data.
Reddy_1
(Berdy)
June 2, 2021, 3:59am
11
you mean like this
System.Text.RegularExpressions.Regex.Match(Broker,“[\w-\ ]+(?= \d{2}/\d{2}/\d{2})|(\w+-\w+-\w+)”).Value
Reddy_1
(Berdy)
June 2, 2021, 4:03am
14
Hi It is giving null value
System.Text.RegularExpressions.Regex.Match(Broker, "[\w\-\ ]+(?= \d{2}\/\d{2}\/\d{2})|(\w+\-\w+\-\w+)").Value
Copy from this
1 Like
Reddy_1
(Berdy)
June 2, 2021, 4:31am
16
Yes still giving me null or empty value.
Try Using matches activity.
In this activity you can check your regex result as they get higlighted
Use for loop to get the result