|
| 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?
Possible, yes. With one statement, no. :)
You've gotten some good suggestions. INSPECT cannot change the size of
a string with its replacement, so you couldn't replace " A " with " ".
There are several native-COBOL ways to do it (and the RegEx suggestion
is probably the least amount of code for the actual conversion - not
sure how much code you'd have to write to use the external utility).
You could use UNSTRING to break it apart and STRING to put it back
together. You could go in a loop, character by character, and build a
new string as you go. And one word of caution - I believe that a space
passes the ALPHANUMERIC class test.
I'd probably go with UNSTRING/STRING myself, along with generous
comments about what that particular routine does. Check out the options
for UNSTRING, particularly the counts it can return. Using it and a
decent-sized work area, you could write a generic routine that could be
called or performed from other places.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ / \/ _ o ~ Live from Albuquerque, NM! ~
~ _ /\ | ~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ Business E-mail ~ daniel @ "Business Website" below ~
~ Business Website ~ http://www.djs-consulting.com ~
~ Tech Blog ~ http://www.djs-consulting.com/linux/blog ~
~ Personal E-mail ~ "Personal Blog" as e-mail address ~
~ Personal Blog ~ http://daniel.summershome.org ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~
GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ !O M--
V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e h---- r+++ z++++
"Who is more irrational? A man who believes in a God he doesn't see,
or a man who's offended by a God he doesn't believe in?" - Brad Stine
|
|