10-14-2021 11:36 AM
Hi all,
I have a scenario where upstream document has a string field like below. In this string ‘:’ can appear for some records. All I need to find is how many times ‘:’ appears in the string for each record to pass the count.
Eg:
fjhfjh:jfhjhgg:oueru:nvmcb
aklkl:pqooo:
pqos:jfh
akkk
uryt:jdf:cvmb
Expected count result:
3
2
1
0
2
I have tried with available find, contain, indexof expressions. Not suits for this scenario. Can someone have a better trick to find count of a character instances in a string? Kindly help.
Regards,
amardeep
10-14-2021 11:55 AM
I think $inputString.split(':').length - 1
should work.
10-14-2021 01:00 PM
Using regex is also an option:
$inputString.match(/[:]/g).length
10-26-2021 08:42 AM
Thanks all. Let me give a try and get back on this.