---
url: >-
  /statelake/scripting-reference/functions-and-procedures/string-functions/stringcontainsonly.md
---

# StringContainsOnly

**StringContainsOnly** checks the string given by **S**, to see if it is made up of only the characters given by the set of characters in **aValid**. This is useful to check that a string contains only what you want, or what you expect to be there.

Sets of characters can be combined by using a plus sign ( + ) as the union operator.

**Declaration**: Function StringContainsOnly( const S : string; const aValid : TFloChars) : Boolean;

A good example follows..

```pascal
procedure BeforeMapEvent(var Value:Variant);
var
  vDigits, vCurrSym: TFloChars;
  vStr1, vStr2: string;
begin
  vDigits := ['0','1','2','3','4','5','6','7','8','9'];
  vCurrSym := ['$',',','.'];
  vStr1 := '$123.00';                        // digits and currency symbols only
  vStr2 := 'NZD123.00';                      // includes alpha characters

 // test first string ... it should be OK
 If StringContainsOnly(vStr1, vDigits + vCurrSym) then
    LogInfo('String "' + vStr1 + '" contains only 0-9,$,.')
 else
    LogInfo('String "' + vStr1 + '" contains other than 0-9,$,.');

 // test second string ... it should fail
 If StringContainsOnly(vStr2, vDigits + vCurrSym) then
    LogInfo('String "' + vStr2 + '" contains only 0-9,$,.')
 else
    LogInfo('String "' + vStr2 + '" contains other than 0-9,$,.');

end;
```
