"). Some simple strings would be
"This sentence is a string!". Strings can be anything from
"", the empty string, to really long sets of text.
varname[ position ]. Please note that string and array positions in CFML start at 1 and not 0.
len()on a string to get back the number of characters in the string. For instance
Len( "Hello ")would give you back 6 (notice the trailing space is counted). You can also use member functions:
Triminstruction removes leading and trailing spaces and control characters from a string. For instance
Trim("Hello ")would give you back
Hello(notice the trailing space is removed). Combine this with
Len( Trim( "Hello ") )and you would get back
5. You can also use member functions:
Replaceinstruction replaces occurrences of substring1 in a string with substring2, in a specified scope. The search is case sensitive and the scope default is one. For instance,
Replace("Hello", "l", "")would give you back Helo after replacing the first occurrence of l, or
Replace("Good Morning!", "o", "e", "All")would give you Geed Merning!
RemoveCharsto remove characters from a string. For instance,
RemoveChars("hello bob", 2, 5)would give you back hbob.
midinstruction extracts a substring from a string. For instance, I could call
Mid("Welcome to CFML Jumpstart", 4, 12)and it would give you back: come to CFML.
listToArray()which can take any string and convert it to an array according to a delimiter. The default delimiter is a comma
,, but you can use any 1 or combination of characters.
#hashes to output a variable to the stream in context. This means we can interpolate into any string:
#hashes, CFML will interpret the variable. Now try this with a complex variable and see what happens: