2007 Dec 17 2:39 PM
Hi ,
can any one plz send me the code for counting the number of spaces in a particular string.
like if we have the value as 100 00 0000. we must get the out put as 2 .
2007 Dec 17 2:47 PM
data : a type string,
b type string,
c type i,
d type i,
e type i.
a = '100 100 100'.
move a to b.
condense b no-gaps.
c = strlen( a ).
d = strlen( b ).
e = c - d.
write 😕 'number of gaps' , e.
Hi ,
can any one plz send me the code for counting the number of spaces in a particular string.
like if we have the value as 100 00 0000. we must get the out put as 2 .
2007 Dec 17 2:44 PM
try this...
DATA : str TYPE string VALUE '100 00 0000',
str_len TYPE i,
str_len2 TYPE i,
space_count TYPE i.
str_len = STRLEN( str ).
CONDENSE str NO-GAPS.
str_len2 = STRLEN( str ).
space_count = ( str_len - str_len2 ).
WRITE 😕 space_count.
2007 Dec 17 2:47 PM
data : a type string,
b type string,
c type i,
d type i,
e type i.
a = '100 100 100'.
move a to b.
condense b no-gaps.
c = strlen( a ).
d = strlen( b ).
e = c - d.
write 😕 'number of gaps' , e.
2007 Dec 17 2:47 PM
hi Sameer,
1. count the length of the string (with STRLEN...)
2. CONDENSE string NO-GAPS (this will remove all spaces)
3. count the length of the string (with STRLEN...) - again
4. calculate the difference between the first and second count, that will be the number of spaces in your string.
hope this helps
ec
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |