import Text ; // Import the Text standard library // Count the number of characters int n = countText( "AAA/BBB/CCC" ) ; println( n ) ; // Outputs: 11 // Extract substring from index 2 up to (but not including) index 5 string crop = cropText( "AAA/BBB/CCC", 2, 5 ) ; println( crop ) ; // Outputs: A/B // Find the first occurrence of "a/a" int first = findText( "aaa/aaa/aaa", "a/a", FIRST ) ; println( first ) ; // Outputs: 2 // Find the last occurrence of "a/a" int last = findText( "aaa/aaa/aaa", "a/a", LAST ) ; println( last ) ; // Outputs: 6 // Find all occurrences of "a/a" int all[] = findText( "aaa/aaa/aaa", "a/a", ALL ) ; println( all ) ; // Outputs: 2 6 // Find all matches of the regular expression "./." int patternAll[] = findText( "AAA/BBB/CCC", "./.", ALL_PATTERN ) ; println( patternAll ) ; // Outputs: 2 6 // Extract all substrings matching the regular expression "./." string ext[] = extractText( "AAA/BBB/CCC", "./.", ALL_PATTERN ) ; println( ext ) ; // Outputs: A/B B/C // Replace all "a/a" with "@" string repl = replaceText( "aaa/aaa/aaa", "a/a", "@", ALL ) ; println( repl ) ; // Outputs: aa@a@aa