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
|
|
| Alistair 2007-11-01, 7:55 am |
| On 1 Nov, 03:40, "Pete Dashwood" <dashw...@removethis.enternet.co.nz>
wrote:
> "Robert" <n...@e.mail> wrote in message
>
> news:6c8ii3t6r3qr5uhed8mkts2bnamllk8oj4@
4ax.com...
>
>
>
>
>
>
>
>
>
>
>
> An imaginative solution, Robert.
>
> I still prefer:
>
> RegEx.Replace(inputString, @"\s\w+\s", " ") ;
>
> ... which does exactly what the user requested (same as the above), with a
> single statement.
>
> The parameters to the "Replace" function are in 3 parts:
>
> 1. The input string.
> 2. The Regular Expression to be matched.
> 3. The string to replace whatever is matched. (This does NOT have to be the
> same length as what is matched; it can be longer or shorter.)
>
> "Translation":
> @ = what follows is a "verbatim string"; it doesn't need to have slashes
> escaped. This is a C# feature, not part of RegEx.
> \s = match a single white space
> \w = match a single alphanumeric character (the "w" stands for "word")
> + = there MUST be 1, and CAN be many, of the preceding character.
>
> Lastly, the statement specifies that anything found to match, is to be
> replaced by a single space character.
>
> So, ' x ' would match, ' x' would not; ' xxxcv13ed5 ' would match, '
> xxxcv$3ed5 ' would not, and so on...
>
> Pete.
> --
> "I used to write COBOL...now I can do anything."- Hide quoted text -
>
> - Show quoted text -
You both failed the GOOD PROGRAMMERS test as neither of you put
appropriate comments in with your code. :-P
| |
| Pete Dashwood 2007-11-01, 6:55 pm |
|
"Alistair" <alistair@ld50macca.demon.co.uk> wrote in message
news:1193919592.787611.131630@z9g2000hsf.googlegroups.com...
> On 1 Nov, 03:40, "Pete Dashwood" <dashw...@removethis.enternet.co.nz>
> wrote:
>
> You both failed the GOOD PROGRAMMERS test as neither of you put
> appropriate comments in with your code. :-P
>
Do you comment every MOVE statement you write in COBOL?
To a C# or ORACLE Programmer the forms used are as clear as a MOVE statement
would be to a COBOL Programmer.
If you "know the language" then documentation needs to be done at a
CONCEPTUAL level, not at the nitty gritty level. In fact documenting at too
low a level simpy makes your code verbose and difficult to read.
And who told you that GOOD PROGRAMMERS put "appropriate comments" in with
their code? GOOD PROGRAMMERS write code that speaks for itself to another
programmer, and document only the tricky or unusal stuff. Production code is
not intended to be a tutorial for people who are not qualified to maintain
it, or haven't earned the language in use.
Pete.
--
"I used to write COBOL...now I can do anything."
|
|
|
|
|