Can someone help me with this regular expression?

J

james.wooten1

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
 
M

Mike H

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
 
R

Ron Rosenfeld

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
 
R

Ron Rosenfeld

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top