Jump to content
Sign in to follow this  
tony01

StringRegExpReplace problem

Recommended Posts

tony01

Hi erverybody:

I am playing with the StringRegExpReplace function and I want to replace the character "P" with spaces

from the string "P20" and the result should be just the the number 20.

This is my script :

CODE

$sRange = "P20"

$nElement = Number(StringRegExpReplace($sRange, "([a-z][A-Z])", " "))

MsgBox(0, "Range", $sRange & " " & $nElement )

I got as a result 0 , instead of 20.

What is Wrong?? Please help.

Thanks a lot.

Share this post


Link to post
Share on other sites
Uten

What does this show:

$sRange = "P20"
$nElement = StringRegExpReplace($sRange, "([a-z][A-Z])", " ")
MsgBox(0, "Range", $sRange  & " " & $nElement )

EDIT: Then try this: StringRegExpReplace($sRange, "[a-zA-Z]", " ") or $sRange = "pP20"

Edited by Uten

Share this post


Link to post
Share on other sites
tony01

Uten :

Excellent, Now It works .

Thanks very much Uten.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.