IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Find how many times a character occurs in a String


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sowmyasridhar15

New User


Joined: 13 Mar 2008
Posts: 5
Location: Bangalore

PostPosted: Thu Mar 20, 2008 10:25 am
Reply with quote

Hi

I just want to know if there is any method to find a character in a string.

Example: MUSCATINE##IOWA##USA

I need to know how many times '##' occurs in the string...Please help...
Back to top
View user's profile Send private message
daye.Zheng

New User


Joined: 15 Feb 2008
Posts: 22
Location: China

PostPosted: Thu Mar 20, 2008 10:33 am
Reply with quote

Using inspect!
For example:

INSPECT stringdata TALLYING counter FOR ALL "#'

you can got it.
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Thu Mar 20, 2008 11:25 am
Reply with quote

Its
Code:
INSPECT String-data TALLYING counter FOR ALL '##'.

as he asked for '##'
Back to top
View user's profile Send private message
sowmyasridhar15

New User


Joined: 13 Mar 2008
Posts: 5
Location: Bangalore

PostPosted: Thu Mar 20, 2008 11:37 am
Reply with quote

Hi...

Thank You...STRING worked...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 20, 2008 8:00 pm
Reply with quote

Hello,

Quote:
STRING worked...
Please post the STRING code that works.
Back to top
View user's profile Send private message
sowmyasridhar15

New User


Joined: 13 Mar 2008
Posts: 5
Location: Bangalore

PostPosted: Tue Mar 25, 2008 11:46 am
Reply with quote

The code that worked was

Code:
INSPECT String-data TALLYING counter FOR ALL '  '.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Mar 25, 2008 12:30 pm
Reply with quote

how nice. magic code!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Mar 25, 2008 7:43 pm
Reply with quote

Hello,

Quote:
Thank You...STRING worked...

Quote:
The code that worked was

Code:
INSPECT String-data TALLYING counter FOR ALL '  '.


Not to make too fine a point, but the code that worked is an INSPECT rather than some string/unstring operation. Also, the code posted will find spaces rather than #(s) which i believe was the original requirement.

FWIW.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Build a record in output file and rep... DFSORT/ICETOOL 11
Search our Forums:

Back to Top