<?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[Operators for Characters in Text]]></title><description><![CDATA[<p dir="auto"> </p>
<h2><a class="anchor-offset" name="introduction"></a>Introduction</h2>
<p dir="auto">A “text” is also called a “string”. It is made of one or more characters. Each character can be a <strong>letter</strong> (such as “a” or “X”), a <strong>digit</strong> (0 to 9) or a <strong>symbol</strong> (such as “+” or “!”).</p>
<p dir="auto">We can use text to represent all kinds of information, such as the name of a person, the title of a book, or the content of a piece of news.</p>
<p dir="auto">Let’s look at some operator blocks for working with text below.</p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="length-of-a-text"></a>Length of a Text</h2>
<p dir="auto">The “length” of a text refers to <strong>the number of characters in it</strong>.</p>
<p dir="auto">For example, the text “hello” contains 5 letters, so its length is 5. The text “Let’s go!” contains 6 letters and 3 symbols (including the space), so its length is 9.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/05bd4ed1-59a3-43a3-9d10-9a6c890adba4.png" width="500" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="reading-the-character-at-a-position"></a>Reading the Character at a Position</h2>
<p dir="auto">You can get the character at any position in a text using the “letter (position) of (text)” block. Note that this block will not only find the letter by its position, but also find the digit or symbol at a position.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c719b7a2-e008-4fb8-b8c0-5c1687b9d7e7.gif" width="250" /></p>
<p dir="auto"> <br />
Note that if you use a position that is less than 1 or more than the length of the text, this block will report an empty value (not the same as the “space” symbol).</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/df48609a-2fa5-454e-8799-0d03f88638d8.gif" width="250" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="get-the-position-of-a-character"></a>Get the Position of A Character</h2>
<p dir="auto">We can also ask for the position of a character in a text. For example, in the text “abcd”, the letter “b” is at position 2, and “d” is at position 4:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/41bb2ce7-8dfc-488a-b734-a9c26927f7c0.gif" width="300" /></p>
<p dir="auto"> </p>
<p dir="auto">If a text contains the same character multiple times, this block will report the position of the first one:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/cc3feab7-99f5-4873-85f1-ed60f1de3fc1.gif" width="350" /></p>
<p dir="auto"> <br />
If the character is not found in the text, a value of 0 will be reported. Note that upper case and lower case letters are treated as the same.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/71498ed6-a11c-405a-baff-0a913a486096.gif" width="350" /></p>
]]></description><link>https://forum.creaticode.com/topic/142/operators-for-characters-in-text</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 19:33:31 GMT</lastBuildDate><atom:link href="https://forum.creaticode.com/topic/142.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 28 Apr 2022 01:06:05 GMT</pubDate><ttl>60</ttl></channel></rss>