August 22, 2019, 1:12pm
I need to scrap address, phone number and operation hours on daily basis separately from the group of below strings. Could someone help me on this?
“1111MiStreetSanFrancisco,CA44000,USA 222-4444-1111 Hours Sunday 9:00AM-8:00PM Monday 7:00AM-9:00PM Tuesday 7:00AM-9:00PM Wednesday 7:00AM-9:00PM Thursday 7:00AM-9:00PM Friday 7:00AM-9:00PM Saturday 8:00AM-9:00PM”
I need address field with the value “1111MiStreetSanFrancisco,CA44000,USA”
Phone Number field = “222-4444-1111”
Sunday = “9:00AM-8:00PM”, Monday, Tuesday for all the days in separate field or variable
August 22, 2019, 2:37pm
I am able to capture separately using regex but it does not work if i group everything.
For hours - (\d:00AM-\d:00PM) - It highlights all the opening hours
For phone number -
For address - (.+?USA)
I don’t know how to group them together all the required values. Could anyone help me now?
You might consider using just a Split()
address = str.Split(" "c)(0).Trim
phone = str.Split(" "c)(1).Trim
sundayHours = Split(str,"Sunday")(1).Trim.Split(" "c)(0).Trim
mondayHours = Split(str,"Monday")(1).Trim.Split(" "c)(0).Trim
tuesdayHours = Split(str,"Tuesday")(1).Trim.Split(" "c)(0).Trim
this should work if your string is in a consistent format.
If you still prefer Regex, can you upload a .txt file of the string? That way we can test the pattern on the string.
August 22, 2019, 3:06pm
@Boopathi Can you confirm every time format will be same or different
August 22, 2019, 3:07pm
@indra yes time format remains same.
August 22, 2019, 3:12pm
@claytonM string remains consistent but empty spaces we are not able to guess. Please find the some sample text file. I feel it would be good to apply regex.
Ula Operatinghours.zip (325 Bytes)
August 22, 2019, 3:17pm
@Boopathi Read text files line by line and iterate while iterating apply regex
August 22, 2019, 3:24pm
Now iterating is not an issue my regex is not highlighting if i group together.
Now i want everything to get highlighted in one regex and it is not working for me if i group.
You can adjust it to remove empty entries like this:
also, your Regex patterns look good. Why don’t you just have a different pattern for each value instead of grouping them?
In UiPath, you would just do this:
address = Regex.Match(str, addressPattern).Value
phone = Regex.Match(str, phonePattern).Value
hours = Regex.Matches(str, hoursPattern).ToArray
sunday = hours(0)
and so on
I might be wrong on the Matches cause I was going off the top of my head.
You can also use the activities for Match and Matches, but my examples could be used in an Assign.
August 22, 2019, 3:37pm
@Boopathi Use or condition in regex Refer This
August 23, 2019, 1:25pm
@ClaytonM Thank you very much. I applied regex using separate variables and got the required output.
August 23, 2019, 1:25pm
@indra Thanks a lot for your guidance. I got the required output and also implemented.
August 26, 2019, 1:25pm
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.