Split value with ,

Hi All,

I have String variable name is Address.
And Address value is = 1 Training Road, home PL7 9DB.
I need to result
variable 1= 1 Training Road
Variable 2= home
Variable 3= PL7 9DB

Variable Address value will be change for next Address.

Kindly Suggest

1 Like

Hi @Naim,

We can give the correct solution, but can you give me the more sample for the address.

You can use split method, substring, regex to achieve

Regards,
Arivu :slight_smile:

1 Like

Thanks For your reply…
I am giving some more example that i need to split…

Example-1
Address:- Flat 24 & 26, Crawford Towers Gulford GU1 1UP
I need this:
Variable 1 = Flat 24 & 26
Variable 2 = Crawford Towers Gulford
Variable 3 = GU1 1UP

Example-2
Address:- Sheffeild house, sheffield S1 3EZ
I need this:
Variable 1 = Sheffeild house
Variable 2 = sheffield
Variable 3 = S1 3EZ

I need first variable till (Flat 24 & 26) , and second variable before Upper case (Crawford Towers Gulford ) and third last upper case with number(GU1 1UP)

Please let me know if any thing is required…

Best Regards,

Hi,

To split the string in using “,” is simple u just have to have to use the below lines
VariableName.tostring.split(“,”) this will; give u the “Flat 24 & 26” as string one and the rest of the sentence as another variable.

If u want to split other values use Substring or Split the string by space and merge the required.

regards.

Hi @Naim,

Thanks For the input
Example strAddress="Flat 24 & 26, Crawford Towers Gulford GU1 1UP"
Step 1:
Variable1 = strAddress.split(","c)(0)
Step 2:
Variable2a=strAddress.split(","c)(1)
Step 3:
Use Regex to get the variable 3 value
Pattern : [A-Z]+[0-9].*
Step 4:
variable2=variable2a.replace(variable3,"")

Refer : regex101: build, test, and debug regex

Regards,
Arivu :slight_smile:

5 Likes

Hi Arivu,
I have done as suggested by you…
But I am not able to split “Crawford Towers Gulford GU1 1UP” value
I need it in to split value
No 1 before upper case value that is "Crawford Towers Gulford "
and I need “GU1 1UP” in another variable.

Please Suggest