[Pick]
String manipulation functions are available in the following ways:find,findnocase,findoneof,replace,compare
Find: Find (substring, string [, start]), finds the starting position of substring in string, returns a number, and returns 0 if it is not found. This function is case-sensitive, that is, it is a casing-sensitive one.
findnocase: findnocase (substring, string [, start]), using the same find, just a function is case insensitive.
findoneof: Findoneof (Set, string [, start]), this function returns the position of any character in the set where the string first appears, that is, the single character in the set is the first occurrence in the string, and if not, returns 0. This function is case-sensitive.
The test code for the above three functions is as follows:
The test code for the above three functions is as follows:
<!---Compare "find", "Findnocase", "findoneof"--->
<cfset Stringtosearch = "The quick brown fox jumped over the lazy dog." >
<cfoutput>
#stringToSearch #<br>
# #find ("the", Stringtosearch) ##= #find ("the", Stringtosearch) #<br>
# #find ("the", stringtosearch,35) ##= #find ("the", stringtosearch,35) #<br>
# #find ("No such substring", Stringtosearch) ##= #find ("No such substring", Stringtosearch) #<br>
<br>
# #findnocase ("the", Stringtosearch) ##= #findnocase ("the", Stringtosearch) #<br>
# #findnocase ("the", stringtosearch,5) ##= #findnocase ("the", stringtosearch,5) #<br>
# #findnocase ("No such substring", Stringtosearch) ##= #findnocase ("No such substring", Stringtosearch) #<br>
<br>
# #findoneof ("Aeiou", Stringtosearch) ##= #findoneof ("Aeiou", Stringtosearch) #<br>
# #findoneof ("Aeiou", stringtosearch,4) ##= #findoneof ("Aeiou", stringtosearch,4) #<br>
# #findoneof ("@%^* ()", Stringtosearch) ##= #findoneof ("@%^* ()", Stringtosearch) #<br>
</cfoutput>
The results of the Test return are as follows:
The quick brown fox jumped over the lazy dog.
#find ("The", Stringtosearch) #=33
#find ("The", stringtosearch,35) #=0
#find ("No such substring", Stringtosearch) #=0
#findnocase ("The", Stringtosearch) #=1
#findnocase ("The", stringtosearch,5) #=33
#findnocase ("No such substring", Stringtosearch) #=0
#findoneof ("Aeiou", Stringtosearch) #=3
#findoneof ("Aeiou", stringtosearch,4) #=6
#findoneof ("@%^* ()", Stringtosearch) #=0
Compare: compare (string1, string2), hence the name meaning, is a string comparison. Returns 0 if both sides of the string are identical. If they are different, their ASCII values are computed for comparison. If string1 is smaller than string2, 1 is returned and 1 is returned. This function is case-sensitive.
Replace: replace (string, substring1, substring2 [, Scope]), string substitution function, Replace the substring1 in string with Substring2, which is the same usage as replace in ASP. Scope represents the replacement field, for example all represents a replacement.
These are just basic string manipulation functions that are more powerful, such as Refind,rereplace,refindnocase,rereplacenocase , and so on. Mainly uses the regular expression regexp to carry on the matching operation, later talks again.