Home > Archive > Cobol > November 2007 > Re: Help with Inspect _src_ replacing all [SPACE]ALPHANUMERIC[SPACE] by space
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Help with Inspect _src_ replacing all [SPACE]ALPHANUMERIC[SPACE] by space
|
|
| HeyBub 2007-11-01, 7:55 am |
| vferr094@alumni.uottawa.ca wrote:
> Hello, I am wondering if anyone knows wether there is a Cobol symbol
> representation where it can be used in the
>
> INSPECT src_var REPLACING all " ALPHANUMERIC " by " "
>
> I need to replace a space followed by any A-Z or 1-0 followed by
> another space by just a space within a string. I thought perhaps there
> is a symbol in cobol to represent all alphanumeric characters, where
> say '*' was it, something like " '*' " , does anyone know if this is
> possible?
Here's a prototype in seven (essential) statements:
COMPUTE LEN = FUNCTION LENGTH(MYSTRING) - 1
PERFORM VARYING I FROM 2 BY 1 UNTIL I > LEN
IF MYSTRING(I - 1:1) = SPACE
AND MYSTRING(I:1) PERMITTED-CHAR
AND MYSTRING (I + 1:1) = SPACE
MOVE SPACE TO MYSTRING(I:1)
END-IF
END-PERFORM
Where PERMITTED-CHAR is defined as:
CLASS PERMITTED-CHAR 'A' 'B' 'C' 'D' (etc.)
| |
| Robert 2007-11-01, 6:55 pm |
| On Thu, 1 Nov 2007 07:48:11 -0500, "HeyBub" <heybubNOSPAM@gmail.com> wrote:
>vferr094@alumni.uottawa.ca wrote:
>
>
>Here's a prototype in seven (essential) statements:
>
> COMPUTE LEN = FUNCTION LENGTH(MYSTRING) - 1
> PERFORM VARYING I FROM 2 BY 1 UNTIL I > LEN
> IF MYSTRING(I - 1:1) = SPACE
> AND MYSTRING(I:1) PERMITTED-CHAR
> AND MYSTRING (I + 1:1) = SPACE
> MOVE SPACE TO MYSTRING(I:1)
> END-IF
> END-PERFORM
>
>Where PERMITTED-CHAR is defined as:
>
>CLASS PERMITTED-CHAR 'A' 'B' 'C' 'D' (etc.)
That will eliminate words one letter long. The question was how to eliminate alphabetic
words of any length.
| |
| William M. Klein 2007-11-01, 6:55 pm |
| "Robert" <no@e.mail> wrote in message
news:3jpji3dq3sjk2424kvs012km63fsch6nf0@
4ax.com...
> On Thu, 1 Nov 2007 07:48:11 -0500, "HeyBub" <heybubNOSPAM@gmail.com> wrote:
>
>
> That will eliminate words one letter long. The question was how to eliminate
> alphabetic
> words of any length.
Robert,
What makes you say that was the original question? (read above or to quote
....
"I need to replace a space followed by any A-Z or 1-0 followed by another space
by just a space"
the word "all" appears in "to represent all alphanumeric" but it still appears
to be talking about a single character.
Now, the OP *may* have wanted a routine to replace a "word" - but that wasn't
how I read the request.
--
Bill Klein
wmklein <at> ix.netcom.com
| |
| HeyBub 2007-11-01, 6:55 pm |
| vferr094@alumni.uottawa.ca wrote:
> William M. Klein wrote:
>
> Hey guys!
>
> Well, I tried the suggestion above, and sure enough it worked.
>
> I am sorry for not originally describing the problem very clearly. It
> was somewhere along the lines...
>
> I have a string say- ' big fresh a apple'
> I needed to scrapout the a and replace it with a space, I realize this
> will give me double spaces, but I have a routine later that scrubs off
> additional spaces, which was why I didnt care.
>
> I would have picked perl if I could have done it in any other
> language, the thing is, had to be done in Cobol. I'm a java programmer
> who's been working with Cobol for the last while, so I am still
> transitioning and not quite an expert on it :)
> Thanks again, Van
Ah,
MOVE 1 TO PTR
MOVE 1 TO I
MOVE SPACE TO WORDS.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 50
UNSTRING MYSTRING DELIMITED BY ' ' INTO WORD(I) WITH POINTER PTR
END-PERFORM.
MOVE SPACE TO MYSTRING
MOVE 1 TO PTR
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 50
IF WORD(I)(2:1) NOT = SPACE
STRING WORD(I) DELIMITED SPACE
' ' DELIMITED SIZE
INTO MYSTRING WITH POINTER PTR
END-IF
END-PERFORM
|
|
|
|
|