Version - 2
Release date - 25 January, 2021
Last updated - 3 February, 2021
Write a short description
This is my first extension! This extension provides various methods to help you work with strings. It has 21 blocks. Some of the function names are real functions in the Python programming language (but in lowercase). You can learn these python functions by using these blocks
Add a picture of all the blocks
Documentation
ErrorOccurred
It is called whenever an error occurs. Use the error variable to know what the error is.
AllIndex
Returns the index of all the occurrences of a string - piece
in another string - text
.
Example: text = Good morning everyone, hello everyone? | piece = everyone
returns [14, 30]
.
Capitalize
Capitalizes the first letter of a string - text
.
Example: text = hello, how are you?
returns Hello, how are you?
.
ChangeCase
Changes the case of a string - ‘text’ according to the case given - ‘toCase’.
The valid cases are - upper case
, lower case
, sentence case
, title case
and toggle case
.
If you enter a wrong case, an error will occur.
Example:
-
text = hello everybody | toCase = upper case
returnsHELLO EVERYBODY
. -
text = HELLO EVERYBODY | toCase = lower case
returnshello everybody
. -
text = hello everybody. how are you? | toCase = sentence case
returnsHello everybody. How are you?
. -
text = hello everybody | toCase = title case
returnsHello Everybody
. -
text = hello everybody | toCase = toggle case
returns randomly capitalized and lowered string likeheLlO EveRyboDY
.
Count
Counts the number of occurrences of a string - piece
in another string - text
.
Example: text = I like mangoes, do you like mangoes? | piece = mangoes
returns 2
.
EndsWith
Tells whether a string - text
ends with another string - piece
.
Example: text = I know how to code! | piece = code!
returns true
.
Index
Returns the index of the first occurrence of a string - piece
in another string - text
.
Example: text = Good morning everyone, hello everyone? | piece = everyone
returns 14
.
IsAlpha
Tells whether a string - text
consists of only letters.
Example: text = 1, 2, 3 are numbers
returns false
.
IsAlphaNumeric
Tells whether a string - text
consists of only letters and numbers.
Example: text = Hello, 1 is the best!
returns false
.
IsDigit
Tells whether a string - text
consists of only numbers.
Example: text = 123
returns true
.
IsLower
Tells whether a string - text
is all lowercase.
Example: text =hello
returns true
.
IsTitle
Tells whether a string - text
is in the form of a title (Only the first letter of every word capitalized).
Example: text = The Book Of Light
returns true
.
IsUpper
Tells whether a string - text
is all uppercase.
Example: text = HELLO
returns true
.
Join
Joins a list of strings - texts
with a string - joiner
.
Example: texst = [hello, how, are, you] | joiner = a
returns helloahowaareayou
.
LStrip
Removes spaces from the left of a string - text
.
Example: text =
" Hello!" returns Hello!
.
Partition
Breaks a string - text
into three parts at the first occurrence of a string - piece
and returns a list of the three parts. The three parts are the text before the piece
, the piece
and the text after the piece
Example: text = We all should eat fruits as they are healthy | piece = fruits
returns [We all should eat , fruits, as they are healthy]
.
RIndex
Returns the index of the last occurrence of a string - piece
in another string - text
.
Example: text = Good morning everyone, hello everyone? | piece = everyone
returns 30
.
RPartition
Breaks a string - text
into three parts at the last occurrence of a string - piece
and returns a list of the three parts. The three parts are the text before the piece
, the piece
and the text after the piece
Example: text = We all should eat healthy fruits and healthy vegetables | piece = healthy
returns [We all should eat healthy fruits and , healthy, vegetables]
.
RStrip
Removes spaces from the right of a string - text
.
Example: text =
"Hello! " returns Hello!
.
Title
Converts a string - text
into the title form (Only the first letter of every word capiatlized).
Example: text = the book of light
returns The Book Of Light
.
Substrings
Returns a list of all the sub-strings of a string - text
of a specific length - length
.
Example: text = banana | length = 2
returns [ba, an, na, an, na]
.
Some extra info
All indexes start from 1.
Every method returns error
if an error occurs.
Download link
Direct Download - com.sumanyu.StringFunctions.aix (28.9 KB)
Thanks to everybody who helped me in the community with my questions!
I hope you like this extension, if so please leave a like!
If you have any suggestions, do tell me!