I need to check range of mixed substring

73 views Asked by At

I have a string and say I want to check the last 3 digits of the string for some range.

if the string is like sasdaX01, I need to check the last three digits of the string are between X01-X50.

ANy help would be highly appreciated.

1

There are 1 answers

0
KerCodex On

The use spl.string::*; line is mandatory and then you extract your last digits with substring(info, length(info) - 3, 3).

An example:

use spl.string::*;
composite TestComposite {
    graph
// ... code generating (stream<rstring info> testStream)

        () as PrintTestInfo = Custom(testStream as infoEvents) {
            logic
                onTuple infoEvents : {
                    rstring lastDigits = substring(info, length(info) - 3, 3);
                    boolean matched = (lastDigits >= "X01" && lastDigits <= "X50");
                    println(info + " matched > " + (rstring)matched) ;
                } // onTuple infoEvents
        } // PrintTestInfo
} // TestComposite