ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Can someone help me with this regular expression? (https://www.excelbanter.com/excel-discussion-misc-queries/223752-can-someone-help-me-regular-expression.html)

[email protected]

Can someone help me with this regular expression?
 
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

Mike H

Can someone help me with this regular expression?
 
Your going to have to clarify what you mean.

Which lower characters of the ASCII range 0 - 127 ? Are you saying you want
to return and what does return mean? Do you simply mean ASCII 97 - 122?

Give some sample data and the result you expect from that data.

Mike

" 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


Ron Rosenfeld

Can someone help me with this regular expression?
 
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

Ron Rosenfeld

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


All times are GMT +1. The time now is 02:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com