Skip to content
EspañolWorkspace →

PSeInt SubCadena: take part of a text

Takes a piece out of a text, from one position to another (both included).

Template
SubCadena
Open it in Codoritmo

Opens the editor with this example loaded. Run it step by step and watch the flowchart.

Worked example

A complete algorithm, ready to copy and run.

subcadena-substring.psc · 3 lines
Algoritmo Example    Escribir SubCadena("pseudocodigo", 1, 6)FinAlgoritmo

Output

Shows: pseudo

This is what the console shows when the example runs.

pseudo

Common mistake

Depending on the profile, the first letter is at position 1 or 0.

Some details depend on your school's profile. See the language profiles.

In a flowchart

This is how it appears in a flowchart, with the same shapes Codoritmo draws.

ini ← SubCadena(s, 1, 3)
Used inside a calculation. It has no shape of its own; it's used inside a calculation. Flowchart: a process rectangle reading "ini ← SubCadena(s, 1, 3)", with one arrow in and one arrow out.
Draw the flowchart of your own algorithm →

Template

The general form. Replace what's inside < > with your own data.

SubCadena · 1 line
SubCadena(<cadena>, <inicio>, <fin>)

Examples that use it

Programs from the example library where it appears, from the simplest to the most complete.

  • Name Initials

    Gets the initials of a full name.

    Beginner
  • Palindromes

    Checks whether a phrase reads the same forwards and backwards.

    Intermediate
  • Count Vowels

    Counts the vowels, spaces and other characters in a text.

    Intermediate
  • Data Formatting

    Fixes upper and lower case, and converts between text and numbers.

    Intermediate
  • Reusable Validation

    Validates the email and age on a sign-up form.

    Intermediate
  • Caesar Cipher

    Encrypts a message by shifting each letter of the alphabet.

    Advanced
See every Text example →

More string functions

Codoritmo is an independent, open-source project inspired by PSeInt and compatible with its syntax. It is not affiliated with the PSeInt project. Official PSeInt website.