1

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"

2 Answers2

1

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
0
regexCount("Aasd,LLLL,xxx", ",")
Hanwei Tang
  • 413
  • 3
  • 10