You mentioned using regex for this. It is true that the Access db engine does not support regular expressions directly. However, it looks like you are ready to use the custom VBA function in your request ... and UDF can use the regex approach. This approach should be simple, easy and faster than repeating each character of the input line and saving only those characters that you want to keep in a new output line.
Public Function OnlyDigits(ByVal pInput As String) As String Static objRegExp As Object If objRegExp Is Nothing Then Set objRegExp = CreateObject("VBScript.RegExp") With objRegExp .Global = True .Pattern = "[^\d]" End With End If OnlyDigits = objRegExp.Replace(pInput, vbNullString) End Function
Here is an example of this function in the Immediate window with the characters "x" as a proxy for your invisible characters. (Any characters not included in the character class "digits" will be discarded.)
? OnlyDigits("x1x23x") 123
If this is what you want, just use the function in your request.
SELECT OnlyDigits(SomeCol) FROM SomeTable;
Hansup
source share