Trim, Split, Replace , Remove New lines space from a variable

Hi I’m in a learning phase of UiPath studio
Hi I get the address from a website like this in a variable BusinessA
image

  1. I want to get the address from a website in a variable BusinessA 12204 SW 131ST AVE MIAMI, FL 33186 (In one single line)
    I’m trying
    (Here BusinessA is my variable name)
    But it does not do anything
    can anyone help me to solve this
  2. 2nd my address is stored in a variable BusinessA (I want to get 33186 From this address that will be stored in another variable like zip_code = 33186 )
  3. I want State from this address in another variable (That is it shows output like state = FL)
  4. I want my address till 12204 SW 131ST AVE MIAMI (and stores it in another variable)

@Aima_Arif

  1. Single line → BusinessA = (BusinessA.Replace(Environment.Newline," ")).Trim
  2. Use assign acitivity → System.Text.RegularExpressions.Regex.Match(BusinessA,“(?<=FL\s)[\d.]+”).Value
  3. Use assign acitivity → System.Text.RegularExpressions.Regex.Match(BusinessA,“(?<=,\s)\w{2}”).Value
  4. Use assign acitivity → System.Text.RegularExpressions.Regex.Match(BusinessA,“(.*?(?=,))”).Value

Thanks but If its not FL? then I mean it can be any state
the how 2 point will be ?

ok Let me make it generic. I considered fix format

Hi @Aima_Arif ,

Could you also maybe provide some other data samples, to check from our end if the pattern is as expected.

Thanks the format is changing for every address extraction :slight_smile : )

Means zip code, state and address can be different every time

give us 2,3 examples…format should be fix but state/zip can be change

sure
image
image
image
These are the different patterns of the generated address

@Aima_Arif zip code, state. address can be different but position remains same…right?

These are different samples of address generated

image
image
image

Yes kind of … I have given you more sample examples you can take an idea

1st one doesn’t do anything result remains same
image

@Aima_Arif

Please try these(Assume str is where variable is stored)

Use them in assign

  1. To remove newline characters - str = System.Text.RegularExpressions.Regex.Replace(str,"\s"," ")
  2. Get pin code - pin = System.Text.RegularExpressions.Regex.Match(str,"\d+\s*$").Value
  3. To Get the country we see that always remaining address and country is separated by comma…so first after getting the pincode we can use replace to remove it and then split of comma…and get the first part as address and second part as country

address = str.Replace(pin,"").Trim.Split({","},StringSplitOptions.None)(0)
country = str.Replace(pin,"").Trim.Split({","},StringSplitOptions.None)(1)

cheers

1 Like

Thanks You so much
image
How to Remove long space between DR PLANTATION

@Aima_Arif

Please try this

  1. To remove newline characters - str = System.Text.RegularExpressions.Regex.Replace(str,"\s+"," ")

cheers

1 Like

Thank you so much
Issue Resolved :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.