Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. 2D Blocks
  4. Operators for Characters in Text

Operators for Characters in Text

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

     

    Introduction

    A “text” is also called a “string”. It is made of one or more characters. Each character can be a letter (such as “a” or “X”), a digit (0 to 9) or a symbol (such as “+” or “!”).

    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.

    Let’s look at some operator blocks for working with text below.

     
     

    Length of a Text

    The “length” of a text refers to the number of characters in it.

    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.

     
     

    Reading the Character at a Position

    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.

     
    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).

     
     

    Get the Position of A Character

    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:

     

    If a text contains the same character multiple times, this block will report the position of the first one:

     
    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.

    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode