Working with expressions

findall() | similar()

LEGEND:

! - Required parameters

Search in a string using a regular expression

findall(reg, str, index) - to find all group matches in a string

Parameters:

! reg - regular expression

! str - string in which search is performed

index - index of found result. It starts at zero. That means the first found result has index 0.

String comparison with typo tolerance

similar(str1, str2) - compares two strings allowing for typos. Returns True if the strings differ by less than 30%.

Example

Let’s look at an example of searching for a string using a specified regular expression:

The result is the following:

Example of using the typo-tolerant string comparison function:

In the start block, we add our riddle in the message section. Then, we also add the answer to our riddle in the calculator using the variable:

riddle = 'cold'.

In the second block, we enter the following expression into the calculator:

response = if(similar(riddle, question) == True, "super!", "Nooo! it's a #{riddle}").

Don’t forget to add #{response} to the message section.

Code
a = findall('.ai\/(.+)\/', 'https://payform.com/ab252acn/', 0)

response = if(similar(riddle, question) == True , "super!", "Nooo! it's a #{riddle}")

Last updated