In some scenarios, such as in public surveys where JavaScript cannot be used, a simple string search can become a rather cumbersome task.
Imagine the following situation:
if(
regex(substr(${codigo}, 0, 5), '^#EXT#$'),
0,
if(
regex(substr(${codigo}, 1, 6), '^#EXT#$'),
1,
if(
regex(substr(${codigo}, 2, 7), '^#EXT#$'),
2,
if(
regex(substr(${codigo}, 3, 8), '^#EXT#$'),
3,
if(
regex(substr(${codigo}, 4, 9), '^#EXT#$'),
4,
if(
regex(substr(${codigo}, 5, 10), '^#EXT#$'),
5,
if(
regex(substr(${codigo}, 6, 11), '^#EXT#$'),
6,
if(
regex(substr(${codigo}, 7, 12), '^#EXT#$'),
7,
if(
regex(substr(${codigo}, 8, 13), '^#EXT#$'),
8,
if(
regex(substr(${codigo}, 9, 14), '^#EXT#$'),
9,
if(
regex(substr(${codigo}, 10, 15), '^#EXT#$'),
10,
if(
regex(substr(${codigo}, 11, 16), '^#EXT#$'),
11,
if(
regex(substr(${codigo}, 12, 17), '^#EXT#$'),
12,
if(
regex(substr(${codigo}, 13, 18), '^#EXT#$'),
13,
if(
regex(substr(${codigo}, 14, 19), '^#EXT#$'),
14,
if(
regex(substr(${codigo}, 15, 20), '^#EXT#$'),
15,
if(
regex(substr(${codigo}, 16, 21), '^#EXT#$'),
16,
if(
regex(substr(${codigo}, 17, 22), '^#EXT#$'),
17,
if(
regex(substr(${codigo}, 18, 23), '^#EXT#$'),
18,
if(
regex(substr(${codigo}, 19, 24), '^#EXT#$'),
19,
"Error #EXT# not found 20 Trys"
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
And
if(
regex(substr(${codigo}, int(${extposition}) + 5, int(${extposition})+12), '^\d{3,5}#$'),
substr(${codigo}, int(${extposition}) + 5, int(${extposition})+11),
if(
regex(substr(${codigo}, int(${extposition}) + 5, int(${extposition})+11), '^\d{3,5}#$'),
substr(${codigo}, int(${extposition}) + 5, int(${extposition})+10),
if(
regex(substr(${codigo}, int(${extposition}) + 5, int(${extposition})+10), '^\d{3,5}#$'),
substr(${codigo}, int(${extposition}) + 5, int(${extposition})+9),
substr(${codigo}, int(${extposition}) + 5, int(${extposition})+8)
)
)
)
To address this, introducing a string search function that can find specific patterns or text within a larger string would be ideal.
This function could take a target pattern (like a keyword, number, or regex) as input and efficiently locate or extract matching parts of the string.
Functions like REGEXEXTRACT or even basic substring matching would simplify the logic and make it easier to handle such scenarios without relying on additional libraries or advanced tools.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.