ScripticXLearn programming visually
Platform
Problems
Community
Leaderboard
Learn
Docs
MiniScript+ basicsVariablesOperators and expressionsInput and outputConditions and decisionsLoopsStringsSums, counts, and extremaDigits of a numberDivisibility and prime numbersNumeric sequences and recurrencesNumber basesFunctions and parametersRecursion
Examples
Basic programsConditionsInput and outputLoopsAlgorithmsWorking with textDigit problemsBase conversionsFunctions and recursionEncode text with a key
What's newHelpContact
Loading…

Examples

MiniScript+

ExamplesMiniScript+
Fundamentals
Basic programsConditionsInput and output
Programming patterns
LoopsAlgorithmsWorking with textDigit problemsBase conversionsFunctions and recursionEncode text with a key
Examples/Working with text

Working with text

Count vowels, check palindromes, and find overlapping matches.

On this page
Count vowels regardless of caseReverse and check a palindromeCount overlapping matchesTry it

These programs use the functions from strings. Positions begin at 0; LEN gives the character count.

Count vowels regardless of case#

MS+MiniScript+
1text = LOWER("Ana are mere")2vowels = 03FOR i FROM 0 TO LEN(text) - 14  IF FIND("aeiou", CHAR(text, i)) != -1 THEN5    vowels = vowels + 16  END7END8PRINT vowels

The result is 6. LOWER normalizes case; FIND != -1 checks membership in the chosen alphabet. Only the five vowels written in the code are recognized; extend the search string for other letters. Empty input gives 0.

Reverse and check a palindrome#

MS+MiniScript+
1text = "radar"2reversed = ""3FOR i FROM LEN(text) - 1 TO 0 INCR -14  reversed = reversed + CHAR(text, i)5END6PRINT reversed7PRINT text == reversed

The output is radar, then TRUE. With "ab", it is ba, then FALSE. Comparison is exact: case, spaces, and punctuation count. Under this convention, empty text is a palindrome. Reversal operates on Unicode code points rather than composed visual symbols.

Count overlapping matches#

MS+MiniScript+
1text = "banana"2pattern = "ana"3count = 04IF LEN(pattern) > 0 THEN5  FOR i FROM 0 TO LEN(text) - LEN(pattern)6    IF SUBSTR(text, i, LEN(pattern)) == pattern THEN7      count = count + 18    END9  END10END11PRINT count

The result is 2: matches start at positions 1 and 3. Advancing one position at a time includes overlaps. This example defines an empty pattern as having zero matches. A pattern longer than the text is not found.

Try it#

Set the text to "aaaa" and pattern to "aa": expect 3. Test an absent pattern and empty text. Use small inputs; repeated operations on immutable strings can become costly for large text.

PreviousAlgorithmsNextDigit problems

On this page

Count vowels regardless of caseReverse and check a palindromeCount overlapping matchesTry it