View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Can someone help me with this regular expression?

On Tue, 10 Mar 2009 15:24:49 -0400, Ron Rosenfeld
wrote:

On Tue, 10 Mar 2009 09:35:32 -0700 (PDT), wrote:

Hello,

I would like to be able to create a regular expression that will only
return the lower ascii characters (ie: 0-127), and replace all other
characters with a carriage return. Can anyone tell me the regex for
this?

Thanks,
James


The regex to match all ASCII characters that are NOT in the range of 0-127
would be:

[^\x00-\x7F]

For the replacement, you will need to literally insert the ascii code 10 as I
don't believe VBSCript supports the tokens in replacement text.

In VBA, you would set the replacement text to Chr(10).

If you are entering it in a worksheet cell, you would hold down the <alt key
and type 0010 on the numeric keypad.
--ron


Just to clarify, the Replace method will replace all characters that match with
the replacement string and leave alone the unmatched characters.

The Regex above will match all characters that are NOT in the lower ascii
range.

Hence the lower ASCII characters will be unchanged; and the upper one's will be
replaced with the replacement string -- Chr(010) in this case.
--ron