cancel
Showing results for 
Search instead for 
Did you mean: 

Regexp only digits from varchar

Former Member
0 Kudos
2,246

Hello,

is there an easy way to select only the digits from a varchar column in Sqlanywhere 12 or 16? I would like to remove all other chars than digits from the varchar. (1234)56/78 should be 12345678.

Thank you Andreas

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Regular Expressions are useful in search criteria but not really applicable to string manipulation. You can try using the REPLACE() function, as in:

select replace( replace( replace('(1234)56/78','(','') ,')','') ,'/','')

And yes, there are 3 nested calls to this function, 1 per character to be replaced.

VolkerBarth
Contributor
0 Kudos

Look at that other FAQ with a similar, although more general topic:

How to strip several different characters from a string?

Mark's first sample should do the trick.