Help with substring

Have looked at all the examples and tutorials but still can’t get substrings to work. In the attached file, my understanding is that I’ve asked the filter to look at column 0 and bring back any entries that match the first two letters of the text input field beginning with the first letter.

But, alas, no such thing is happening, Any help or ideas gratefully accepted.
substring.rp (5.9 MB)

Hi!

Filters need to be designed to return true or false. .If you just want the first two characters to match between the field and Column0, you could say…

[[Item.Column0.substr(0, 2) == LVAR1.substr(0,2) ]]

…which assuming LVAR1 has the value of the text field, says “show a row if the first two characters of Column0 equals the first two characters of the field.”

If you want the starting characters matching no matter what the length, you could say:

[[Item.Column0.indexOf(LVAR1) == 0]]

This will return true if the beginning of the string in the field matches the beginning of the string in Column0.

Remember that string matching is case sensitive, so here are the corresponding two expressions that don’t care about case.

[[Item.Column0.substr(0, 2).toLowerCase() == LVAR1.substr(0,2).toLowerCase() ]]

[[Item.Column0.toLowerCase().indexOf(LVAR1.toLowerCase()) == 0]]

Thanks so much or your help and wisdom. jospehxbrick

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.