How to split value after certain place

I need to split the value of x and y
For ex:{X=160,Y=220,Width=1122,Height=334}
Output should be 160
And second output should be 220

Hi @sruthesanju

Split based on equals sign

split(yourvariable,"=")

You arrayvalue(1) contains your string value.

Regards

1 Like

Hello,

yourString.Split(",β€œc)(0).Split(”="c)(1).ToString gives X.

yourString.Split(",β€œc)(1).Split(”="c)(1).ToString gives Y.

Hope it helps !

Hi @sruthesanju

you can use Split Function to split the string using the comma
YourString.Split(",β€œc)(0).Split(”=β€œc)(1).ToString β†’ The output is: 160
YourString.Split(”,β€œc)(1).Split(”=β€œc)(1).ToString β†’ The output is: 220
YourString.Split(”,β€œc)(2).Split(”=β€œc)(1).ToString β†’ The output is: 1122
YourString.Split(”,β€œc)(3).Split(”="c)(1).ToString β†’ The output is: 334

Or you can use Substring function.
YourStringVariable.Substring(StartIndex,Length)
For Example: you have the string variable: MyText = β€œHello World”
MyText.Substring(0,2) -->This gives you the output: He
MyText.Substring(0,4) -->This gives you the output: Hell
MyText.Substring(3,2) -->This gives you the output: lo

For your string: β€œX=160,Y=220,Width=1122,Height=334”
MyText.Substring(2,3) -->This gives you the output: 160
MyText.Substring(8,3) -->This gives you the output: 220

Best regards
Mahmoud

1 Like

Your case looks like the text representation of a variable of Datatype Rectangle displayed e.g. in Locals / Watch immediate panel or ToString method.

grafik

In such case we can get the value directly from the property by the API
Have look here:
grafik

1 Like

@sruthesanju you can try regex.

Pattern for X : (?<=X=)(\d)+
Pattern for Y : (?<=Y=)(\d)+

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