Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: Help with Inspect _src_ replacing all [SPACE]ALPHANUMERIC[SPACE] by space

"Robert" <no@e.mail> wrote in message
 news:6c8ii3t6r3qr5uhed8mkts2bnamllk8oj4@
4ax.com...
> On Wed, 31 Oct 2007 12:00:39 -0700, vferr094@alumni.uottawa.ca wrote:
> 
>
> You can do it yourself like this:
>
> move 1 to pos-in pos-out
> move spaces to string-out
> perform until pos-in > length of string-in
>    move spaces to a-word
>   unstring string-in delimited by ALL SPACE
>        into a-word with pointer pos-in
>   move a-word to temp-word
>   inspect temp-word converting
>         'abcdefghijklmnopqrstuvwxyz0123456789' to space
>   if  temp-word equal to spaces
>       move spaces to a-word
>   end-if
>   string a-word delimited by space
>              space
>        into string-out with pointer pos-out
> end-perform

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."




Report this thread to moderator Post Follow-up to this message
Old Post
Pete Dashwood
11-01-07 08:55 AM


Re: Help with Inspect _src_ replacing all [SPACE]ALPHANUMERIC[SPACE] by space
On Thu, 1 Nov 2007 16:40:28 +1300, "Pete Dashwood" <dashwood@removethis.ente
rnet.co.nz>
wrote:

>
>
>"Robert" <no@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...

If he had access to Oracle 10, he could use Posix notation, which is easier 
to read:

SELECT REGEXP_REPLACE
(:string-in,
'[:space:][:alpha:]+[:space:]',
' '
)
INTO :string-out
FROM dual

Report this thread to moderator Post Follow-up to this message
Old Post
Robert
11-01-07 08:55 AM


Re: Help with Inspect _src_ replacing all [SPACE]ALPHANUMERIC[SPACE] by space

"Robert" <no@e.mail> wrote in message
 news:ukpii39nk01e9c399rttdhguk9o81dnojb@
4ax.com...
> On Thu, 1 Nov 2007 16:40:28 +1300, "Pete Dashwood"
> <dashwood@removethis.enternet.co.nz>
> wrote:
> 
>
> If he had access to Oracle 10, he could use Posix notation, which is
> easier to read:
>
> SELECT REGEXP_REPLACE
>      (:string-in,
>       '[:space:][:alpha:]+[:space:]',
>       ' '
>      )
>       INTO :string-out
>  FROM dual

Excellent!

I didn't know you could do that with ORACLE :-)

Pete.
--
"I used to write COBOL...now I can do anything."




Report this thread to moderator Post Follow-up to this message
Old Post
Pete Dashwood
11-01-07 11:55 PM


Re: Help with Inspect _src_ replacing all [SPACE]ALPHANUMERIC[SPACE] by space
In article <5ov3diFoodpjU1@mid.individual.net>,
Pete Dashwood <dashwood@removethis.enternet.co.nz> wrote:
>
>
>"Robert" <no@e.mail> wrote in message
> news:ukpii39nk01e9c399rttdhguk9o81dnojb@
4ax.com...

[snip]
 
>
>Excellent!
>
>I didn't know you could do that with ORACLE :-)

I believe, Mr Dashwood, that one can do such things with Oracle version 10
or higher; I do not recall it being a part of version 9i when I studied
such.

DD


Report this thread to moderator Post Follow-up to this message
Old Post

11-02-07 12:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 02:35 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.