How To Fetch Data using Keywords

Below are the key words which are present in an array
{ “ST”, “RD”, “STREET”, “ROAD”, “AVE”, “AVENUE”, “TERRACE”, “CT”, “CCT”, “ARC”, “Link”, “TCE”, “SQ”, “SQUARE”, “RIDGE”, “RDGE”, “PLACE”, “PL”, “CLOSE”, “VOULEVARD”, “ALLEY”, “Jnc”, “PARADE”, “PDE”, “LANE”, “HIGHWAY”, “HWY”, “GROVE”, “GR”, “CL”, “BVD”, “ALLY”, “Mews”, “ESPLANADE”, “ESP”, “DRIVE”, “DR”, “CRESCENT”, “CRES”, “COURT”, “CIRCUIT”, “ARCADE”, “STRT”, “Boulevard”, “Bypass”, “Bypa”, “Corner”, “Crn”, “Cul-de-sac”, “Cds”, “Green”, “Grn”, “Junction” }
How to match above keywords with the below given Texts
if in given text a keyword is found, then need to extract the text prior to keyword as an address
text suffix to keyword need to extract as an suburb

5A NORTH WEST ARM ROAD GYMEA
14 SASSAFRAS ST PARKLEA
83 BLANDFORD STREET COLLAROY PLATEAU NSW
6 HARSTON AVENUE MOSMAN SYDNEY

1 Like

Hey @srujana13a5

Here is the demo code attached - nmnithinkrishna_FrameAddressWithKeywords.zip (3.0 KB)

//Output

nmnithinkrishna_UiPath

Hope this helps.

Thanks
#nK

Thanks for the quick response

For Address part i need to add match keyword also can

5A NORTH WEST ARM ROAD
14 SASSAFRAS ST
83 BLANDFORD STREET

Can you please help

Hey @srujana13a5

Yes of course, you can just concatenate the arr linq used in the First function.

Kindly try the same, if required more help let me know.

Thanks
#nK

match one I need to connect can you help

Hey @srujana13a5

Please update the below in the first Assign,

item.Split({arrStr_Keywords.First(Function(obj) item.Split(" ".ToCharArray, StringSplitOptions.RemoveEmptyEntries).Contains(obj))}, StringSplitOptions.RemoveEmptyEntries).First().Trim + arrStr_Keywords.First(Function(obj) item.Split(" ".ToCharArray, StringSplitOptions.RemoveEmptyEntries).Contains(obj))

Hi @srujana13a5 ,

Maybe the below could be an alternate Solution :

  1. Considering that the keywords are present in an Array of String variable, say keywords.

  2. We can prepare the Regex Expression by using the below Expression :

regexExp = "(.*)(?<="+String.Join("|",keywords.Select(Function(x)"\b"+x+"\b").ToArray)+")(.*)"

Here, regexExp is a variable of type String.

  1. Regex Expression generated would be similar to the below manner :

We could get the Group 1 and 2 as the Address and Suburb accordingly.

  1. Expression to be used :
    For Retrieving the Address :
Regex.Match(InputStr,regexExp).Groups(1)

For Retrieving the Suburb:

Regex.Match(InputStr,regexExp).Groups(2)

image