cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1123
Views
0
Helpful
2
Replies

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

susanto.liu
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

Aaron Harrison
VIP Alumni
VIP Alumni

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...

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!

View solution in original post

2 Replies 2

Aaron Harrison
VIP Alumni
VIP Alumni

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...

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!

Thank You, aaronharrison . It's solve my problem.