How to return the number of a specified character in a String, such as the number of comma in the following String:
"Aasd,LLLL,xxx"
How to return the number of a specified character in a String, such as the number of comma in the following String:
"Aasd,LLLL,xxx"
DolphinDB‘s function regexCount
can meet your demands. You can try the script:
str = "Aasd,LLLL,xxx"
regexCount(str, ",")
Also, regexCount can return the number of all occurrences of a regular expression, see regexCount — DolphinDB 2.0 documentation for its reference.
Alternatively, you can also use the function split
to count the size of the vector output, like:
split(str, ",").size() - 1