2

I am looking for the best method to remove digit characters from ASCII text within Sybase SQL Anywhere 16. Is there any method of doing this which does not resort to nested REPLACE() calls, loops etc.?

Example:

This 1.00 is 200 a test 333 string. becomes This is a test string.

telenachos
  • 884
  • 6
  • 18
  • See my rewritten answer on [this post](http://stackoverflow.com/questions/36020273/regex-to-match-all-non-digit-characters-which-are-interspersed-with-digits/36020483#36020483). It has an example from Sybase docs using lookarounds that you mentioned, on a nearly identical problem. Apologies if you saw this already. – zdim Mar 17 '16 at 07:26

2 Answers2

0

As ASE supports regular expressions:

REGEXP_REPLACE(str, ' *[[:digit:]]+.?[[:digit:]]+', '')

This removes [decimal] numbers with optional leading spaces.

dnoeth
  • 59,503
  • 4
  • 39
  • 56
  • Unfortunately I am not using ASE and do not have access to REGEXP_REPLACE() or any regex enabled replace functions. SQL Anywhere does provide REPLACE(str, find_str, replace_str) and REGEXP_SUBSTR(str, regex). If there was a regex to match all alphanumeric characters but not match decimal characters I think I could make it work. – telenachos Mar 15 '16 at 18:52
  • @ldueck: Sorry, I don't think there's any way simple way to do what you want without `REGEXP_REPLACE`. – dnoeth Mar 15 '16 at 21:21
0

If you can assume the digits are always separated from the alphanumeric words, this should work:

SELECT LIST(REGEXP_SUBSTR(tst_string,'(^|[[:blank:]])[[:alpha:]]+', 1, n.row_num),'')
FROM sa_rowgenerator(1,length(tst_string)) n;
Mikel Rychliski
  • 3,455
  • 5
  • 22
  • 29