Search code examples
filemaker

how to find special characters present in a String in FileMaker


When a string has special characters then how to find out in FileMaker scripting.

For example we have ABC$XYZ then in scripting we need to find only charaters like A to Z or a to z or 0 to 1 exist or any other characters also exist


Solution

  • The Filter function combined with the Length function should work for finding out if other characters exist, for example:

    Let ( [
        originalString = "ABC$XYZ";
        originalStringLength = Length ( originalString );
    
        // all characters would need to be listed below
        filterSet = "abcd...zABCD...Z012...9";
    
        filteredString = Filter ( originalString ; filterSet );
        filteredStringLength = Length ( filteredString )
    ] ;
        If ( filteredStringLength = originalStringLength ;
            "No special characters." ;
            "Special characters." )
    )
    

    To find out what those characters are, however, you may need to use the Substitute function.

    Additional reading: