Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

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

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

Everyone's tags (4)
1 ACCEPTED SOLUTION

Accepted Solutions
Super Bronze

Re: how to find out how many space character in setence (string

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!
2 REPLIES
Super Bronze

Re: how to find out how many space character in setence (string

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!
New Member

Re: how to find out how many space character in setence (string

Thank You, aaronharrison . It's solve my problem.
417
Views
0
Helpful
2
Replies