how to find out how many space character in setence (string var) ?

Answered Question
Jul 30th, 2010
User Badges:

Dear all Master,


I need Your help please.


Topic:

Script Editor.


My System:

-CUCM 7.0

-UCCX 7.0 premium

-Nuance recognizer 9.0


Question:

ABC = string var.

ABC = "this is sample"

2 space character in ABC string var.


How to find out how many space character in ABC var ?



Regards,

Susanto

Correct Answer by Aaron Harrison about 6 years 9 months ago

Hi


Create a int variable called whatever you want, then insert a SET step.


Set the variable to the new int you created, and then paste this into the 'value' field:


{
String[] myarray = teststring.split(" ");
return myarray.length -1 ;
}


Basically it splits the string into chunks each time it hits the " " character.


This results in an array of the resulting chunks (i.e. words), which is one more than the number of spaces. -1 from that, and you have your int variable set to the number of spaces.


Regards


Aaron


Please rate helpful posts...

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
Correct Answer
Aaron Harrison Fri, 07/30/2010 - 02:51
User Badges:
  • Super Bronze, 10000 points or more
  • Community Spotlight Award,

    Member's Choice, May 2015

Hi


Create a int variable called whatever you want, then insert a SET step.


Set the variable to the new int you created, and then paste this into the 'value' field:


{
String[] myarray = teststring.split(" ");
return myarray.length -1 ;
}


Basically it splits the string into chunks each time it hits the " " character.


This results in an array of the resulting chunks (i.e. words), which is one more than the number of spaces. -1 from that, and you have your int variable set to the number of spaces.


Regards


Aaron


Please rate helpful posts...

Actions

This Discussion

Related Content