<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[UIFlow - Trimming Strings]]></title><description><![CDATA[<p dir="auto">I had an issue with processing json data that would not parse because it had a [ at the start and a ] at the the end.<br />
There is no easy way to remove these characters.</p>
<p dir="auto">There is a trim spaces block.<br />
What would be good would be a version of this block that trims ANY characters from the ends of a string.   It would also act as a substr option.</p>
<p dir="auto">My clunky work around was:</p>
<ul>
<li>Replace all spaces with a couple of ££ characters.</li>
<li>Replace all the [  with spaces.</li>
<li>Use the trim spaces block</li>
<li>Replace all spaces with [</li>
<li>Replace all the ]  with spaces.</li>
<li>Use the trim spaces block</li>
<li>Replace all spaces with ]</li>
<li>Replace all the ££s with a space.</li>
</ul>
<p dir="auto">Working out what the problem was took a while, but it took longer to find a way to make it work.</p>
]]></description><link>https://community.m5stack.com/topic/3564/uiflow-trimming-strings</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 06:21:15 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/3564.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 05 Sep 2021 23:07:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to UIFlow - Trimming Strings on Fri, 10 Sep 2021 22:45:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/iamliubo" aria-label="Profile: iamliubo">@<bdi>iamliubo</bdi></a> said in <a href="/post/14813">UIFlow - Trimming Strings</a>:</p>
<blockquote>
<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/notdodgy" aria-label="Profile: notdodgy">@<bdi>notdodgy</bdi></a> ,<br />
We will add this block:<br />
<img src="/assets/uploads/files/1630901532999-b47fbc8d-7771-4720-8455-dfaad19ad7f2-image-resized.png" alt="0_1630901532509_b47fbc8d-7771-4720-8455-dfaad19ad7f2-image.png" class=" img-fluid img-markdown" /></p>
</blockquote>
<p dir="auto">Hello -</p>
<p dir="auto">Tried this new trim version and it works fine.<br />
Guessed correctly that I needed to use "[ ]" as the trim characters in the first part.</p>
<p dir="auto">No need for me to use a custom trim function.</p>
<p dir="auto">Thanks</p>
]]></description><link>https://community.m5stack.com/post/14857</link><guid isPermaLink="true">https://community.m5stack.com/post/14857</guid><dc:creator><![CDATA[notdodgy]]></dc:creator><pubDate>Fri, 10 Sep 2021 22:45:24 GMT</pubDate></item><item><title><![CDATA[Reply to UIFlow - Trimming Strings on Thu, 09 Sep 2021 17:10:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/robalstona" aria-label="Profile: robalstona">@<bdi>robalstona</bdi></a> Thanks for your suggestion.</p>
<p dir="auto">The Custom block builder creates the code and the code used in block shown above does work.</p>
<p dir="auto">I opted to have the block and the name of the variable the same.<br />
The variable name appears on the block so effectively names the block.<br />
(If you don't have a variable as input, you can use a label, having both looked confusing and doubled the height of the block ).</p>
]]></description><link>https://community.m5stack.com/post/14852</link><guid isPermaLink="true">https://community.m5stack.com/post/14852</guid><dc:creator><![CDATA[notdodgy]]></dc:creator><pubDate>Thu, 09 Sep 2021 17:10:03 GMT</pubDate></item><item><title><![CDATA[Reply to UIFlow - Trimming Strings on Thu, 09 Sep 2021 10:22:26 GMT]]></title><description><![CDATA[<p dir="auto">Try change name of function or variable. At now they had the same names.</p>
<p dir="auto">Maybe this construction will be work</p>
<pre><code>str(${Trimmer})[1:-1]
</code></pre>
]]></description><link>https://community.m5stack.com/post/14851</link><guid isPermaLink="true">https://community.m5stack.com/post/14851</guid><dc:creator><![CDATA[robalstona]]></dc:creator><pubDate>Thu, 09 Sep 2021 10:22:26 GMT</pubDate></item><item><title><![CDATA[Reply to UIFlow - Trimming Strings on Wed, 08 Sep 2021 23:30:29 GMT]]></title><description><![CDATA[<p dir="auto">I had tried that in a custom block but it didn't work.<br />
Thanks for confirming the syntax.<br />
I spotted that I had misread the custom block syntax rules and had included extra quotes.</p>
<p dir="auto">I now have a working custom block that simply removes the first and last characters.</p>
<p dir="auto">I have an input called Trimmer</p>
<p dir="auto">The code section has ${Trimmer}[1:-1]</p>
<p dir="auto"><img src="/assets/uploads/files/1631143767542-d8bb067c-1d3b-4c4c-8b83-272d56a88d4c-image-resized.png" alt="0_1631143765864_d8bb067c-1d3b-4c4c-8b83-272d56a88d4c-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/14844</link><guid isPermaLink="true">https://community.m5stack.com/post/14844</guid><dc:creator><![CDATA[notdodgy]]></dc:creator><pubDate>Wed, 08 Sep 2021 23:30:29 GMT</pubDate></item><item><title><![CDATA[Reply to UIFlow - Trimming Strings on Tue, 07 Sep 2021 16:05:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/notdodgy" aria-label="Profile: notdodgy">@<bdi>notdodgy</bdi></a><br />
In python this also works</p>
<p dir="auto">out_str = in_str[1:-1]</p>
]]></description><link>https://community.m5stack.com/post/14827</link><guid isPermaLink="true">https://community.m5stack.com/post/14827</guid><dc:creator><![CDATA[robalstona]]></dc:creator><pubDate>Tue, 07 Sep 2021 16:05:25 GMT</pubDate></item><item><title><![CDATA[Reply to UIFlow - Trimming Strings on Mon, 06 Sep 2021 23:27:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/robalstona" aria-label="Profile: robalstona">@<bdi>robalstona</bdi></a> said in <a href="/post/14822">UIFlow - Trimming Strings</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/notdodgy" aria-label="Profile: notdodgy">@<bdi>notdodgy</bdi></a>, show me example input string, and write what exactly you need "extract" from this json string. Show me  what string you except as output according to example input string. It is a some kind of homework?. I don't know why you make so many character substitutions in the text.</p>
<p dir="auto">in python code you could use this construction:</p>
<pre><code>out_str = in_str.replace('[', '').replace(']', '').replace...
</code></pre>
<p dir="auto">but i dont tested yet how long may be replace chain.</p>
</blockquote>
<p dir="auto">Hello.  It's a simple problem but the work around is not.<br />
This is a fairly large chunk of data which is json encoded.<br />
It's provided from a server API which I cannot change.<br />
It's from the servers that control my Car home charger.<br />
I am creating a remote monitor as a simple visual display.  I can also use it to do basic start/stop actions.</p>
<p dir="auto">It contains a number of [ and ]  and spaces in the body which I need to keep unchanged.</p>
<p dir="auto">My simple problem is it has an additional "[" at the start and a "]" at the end.<br />
This extra pair of [ and ] stop "loads json" from working.</p>
<p dir="auto">I only need to lose the first and last characters of the received data, while keeping the rest unchanged.<br />
In other programming languages it would be a substr(data,1,(strlen(data)-2)) or  string[1:-1] .</p>
]]></description><link>https://community.m5stack.com/post/14823</link><guid isPermaLink="true">https://community.m5stack.com/post/14823</guid><dc:creator><![CDATA[notdodgy]]></dc:creator><pubDate>Mon, 06 Sep 2021 23:27:09 GMT</pubDate></item><item><title><![CDATA[Reply to UIFlow - Trimming Strings on Mon, 06 Sep 2021 17:54:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/notdodgy" aria-label="Profile: notdodgy">@<bdi>notdodgy</bdi></a>, show me example input string, and write what exactly you need "extract" from this json string. Show me  what string you except as output according to example input string. It is a some kind of homework?. I don't know why you make so many character substitutions in the text.</p>
<p dir="auto">in python code you could use this construction:</p>
<pre><code>out_str = in_str.replace('[', '').replace(']', '').replace...
</code></pre>
<p dir="auto">but i dont tested yet how long may be replace chain.</p>
]]></description><link>https://community.m5stack.com/post/14822</link><guid isPermaLink="true">https://community.m5stack.com/post/14822</guid><dc:creator><![CDATA[robalstona]]></dc:creator><pubDate>Mon, 06 Sep 2021 17:54:41 GMT</pubDate></item><item><title><![CDATA[Reply to UIFlow - Trimming Strings on Mon, 06 Sep 2021 16:36:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/robalstona" aria-label="Profile: robalstona">@<bdi>robalstona</bdi></a> said in <a href="/post/14819">UIFlow - Trimming Strings</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/notdodgy" aria-label="Profile: notdodgy">@<bdi>notdodgy</bdi></a> there is also <strong>replace</strong> block. It has a three arguments:<br />
first is text to replace in your case <strong>[</strong><br />
second is a replacing text, in your case leave blank.<br />
and third is your text or variable containing it.</p>
</blockquote>
<p dir="auto">That is what I used but to only remove the first and last characters takes a number of search and replaces.</p>
<p dir="auto"><img src="/assets/uploads/files/1630946118514-284d54f5-f2fb-46b4-a7ba-a192657c827f-image-resized.png" alt="0_1630946120197_284d54f5-f2fb-46b4-a7ba-a192657c827f-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/14821</link><guid isPermaLink="true">https://community.m5stack.com/post/14821</guid><dc:creator><![CDATA[notdodgy]]></dc:creator><pubDate>Mon, 06 Sep 2021 16:36:06 GMT</pubDate></item><item><title><![CDATA[Reply to UIFlow - Trimming Strings on Mon, 06 Sep 2021 16:22:59 GMT]]></title><description><![CDATA[<p dir="auto">That is good to hear.</p>
<p dir="auto">I started looking at a custom block but could find the right Python command.</p>
<p dir="auto">string[n:n] does not work.</p>
]]></description><link>https://community.m5stack.com/post/14820</link><guid isPermaLink="true">https://community.m5stack.com/post/14820</guid><dc:creator><![CDATA[notdodgy]]></dc:creator><pubDate>Mon, 06 Sep 2021 16:22:59 GMT</pubDate></item><item><title><![CDATA[Reply to UIFlow - Trimming Strings on Mon, 06 Sep 2021 15:16:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/notdodgy" aria-label="Profile: notdodgy">@<bdi>notdodgy</bdi></a> there is also <strong>replace</strong> block. It has a three arguments:<br />
first is text to replace in your case <strong>[</strong><br />
second is a replacing text, in your case leave blank.<br />
and third is your text or variable containing it.</p>
]]></description><link>https://community.m5stack.com/post/14819</link><guid isPermaLink="true">https://community.m5stack.com/post/14819</guid><dc:creator><![CDATA[robalstona]]></dc:creator><pubDate>Mon, 06 Sep 2021 15:16:00 GMT</pubDate></item><item><title><![CDATA[Reply to UIFlow - Trimming Strings on Mon, 06 Sep 2021 04:12:18 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/notdodgy" aria-label="Profile: notdodgy">@<bdi>notdodgy</bdi></a> ,<br />
We will add this block:<br />
<img src="/assets/uploads/files/1630901532999-b47fbc8d-7771-4720-8455-dfaad19ad7f2-image-resized.png" alt="0_1630901532509_b47fbc8d-7771-4720-8455-dfaad19ad7f2-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/14813</link><guid isPermaLink="true">https://community.m5stack.com/post/14813</guid><dc:creator><![CDATA[IAMLIUBO]]></dc:creator><pubDate>Mon, 06 Sep 2021 04:12:18 GMT</pubDate></item></channel></rss>