help me please i need to replace " in a string

Get help using Construct 2

Post » Tue Jun 28, 2016 1:45 am

im getting data from a websocket server but its comeing through as a string separated by "

so eg

"1253.22"

is there any way i can delete the " " ether side as when i display as text its showing as "1253.22"
B
7
S
2
Posts: 47
Reputation: 1,167

Post » Tue Jun 28, 2016 7:22 am

One way would be to set up a empty variable and set its value to your string with left(), right() or mid() and repeat until you have what you need, but than your string has to be always the same length. A better way would be to use Regex: Exploring Regex in Construct 2
B
11
S
4
G
5
Posts: 74
Reputation: 3,435

Post » Tue Jun 28, 2016 9:37 am

Another way would be to "save" the incoming information in a "number" variable using float() at worst to cast the value as a floating value.
This will directly set the value of the variable to a number and will prevent you having to do any string manipulation.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
294
S
117
G
96
Posts: 7,311
Reputation: 71,086

Post » Tue Jun 28, 2016 9:46 am

Kyatric wrote:Another way would be to "save" the incoming information in a "number" variable using float() at worst to cast the value as a floating value.
This will directly set the value of the variable to a number and will prevent you having to do any string manipulation.

That works best ;) This will come in Handy, i thoght that would make an error, but it work.
B
11
S
4
G
5
Posts: 74
Reputation: 3,435

Post » Tue Jun 28, 2016 2:46 pm

If you have the text in a var you can remove the " with:

set var to replace(var, """", "")
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests