Notifications
Clear all

[Closed] How to find "" inside a string?

I have this string:

"#(#(#p2p, true, #(false, "static"), #((color 0 255 0), (color 0 255 0), (color 0 0 0)), #(#("83.054"", [-31.3552,33.1015,0], [20.9261,-31.4324,0])), #(false, #()), true, undefined))"

The problem is this part:
“83.054″”

It breaks the string. How I can find “” inside the string using matchPattern or findString?

11 Replies

“matchpattern” returns a Boolean so you might find “findstring”, although slower, to be more useful.

matchpattern <string> pattern:"*\"\"*"
findstring <string> "\"\""
1 Reply
(@miauu)
Joined: 10 months ago

Posts: 0

Thank you. It works. For some stupid reasons I tried

matchpattern <string> pattern:"\"\"" 

, but not including *.

it’s better to use findstring in your case. because you have to know where it is as well.

2 Replies
(@miauu)
Joined: 10 months ago

Posts: 0

Yep. I use findString and replace the first with ’ ‘(without the space).

(@polytools3d)
Joined: 10 months ago

Posts: 0

If you need to remove the double quotes, perhaps you could also use:

substitutestring <string> "\"\"" "\""

I need this:

"83.054""

to not brake the whole string, so when I use execute command the returned value to be an array and the

"83.054""

to be read as 83.054″ (decimal inches), but to be a string, so I can assign it where I need.

The ’ ‘(without space) for now is a solution.

use ‘metric’ units. or generic at least.

I always use metric units, but can’t force anyone else to use them.

I mean you could just use “substitutestring” instead of “findstring + replace”. Althought it’s slower, the advantage is that it is only one line and it will replace all the matches in the string.

If you need to replace the Double Quotes by a Double Apostrophe you could use:

substitutestring <string> "\"\"" "''"

Yes, substitutestring() is the solution I use in this scenario.

i’m measuring gas in gallons, driving distance in miles… but i still can’t measure a size in feet/inches