REPLACE([MyField],A-Z Char,"")

mikejaytlabustro

Access Database 2007 PH
Local time
Today, 15:13
Joined
Feb 11, 2013
Messages
93
Hello access programmers!

[MyField] contains for example A1B2C3 or ABC123 or 1E2F3ABCD ...
I want to see a result of 123 using Replace Function

Is it possible?
 
To answer your exact question: No. Replace isn't like perl regular expressions where you can strip out all the letters and leave just the numbers.

My advice would be to create a custom function. You would pass it your string ([MyField]) and it would go through that string character by character, testing to see if that character was a number and then moving those that were to a return variable.

So again, no you cannot do this with a single Replace call. The best method would be to create your own custom function.
 
To answer your exact question: No. Replace isn't like perl regular expressions where you can strip out all the letters and leave just the numbers.

My advice would be to create a custom function. You would pass it your string ([MyField]) and it would go through that string character by character, testing to see if that character was a number and then moving those that were to a return variable.

So again, no you cannot do this with a single Replace call. The best method would be to create your own custom function.

Thank you, i found the perfect solution here https://support.microsoft.com/en-us/kb/99938
 
You could also replace this line...
Code:
If A_Char$ >= "0" And A_Char$ <= "9" Then
with this...
Code:
If IsNumeric(A_Char$) Then
... just one less check.
 

Users who are viewing this thread

Back
Top Bottom