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

asked 11 Feb '16, 08:51

aihbrb's gravatar image

aihbrb
31122
accept rate: 0%


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.

permanent link

answered 11 Feb '16, 09:09

Volker%20Barth's gravatar image

Volker Barth
31.3k312458674
accept rate: 33%

edited 11 Feb '16, 09:10

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.

permanent link

answered 11 Feb '16, 12:17

Nick%20Elson%20SAP%20SQL%20Anywhere's gravatar image

Nick Elson S...
7.3k35107
accept rate: 31%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×2

question asked: 11 Feb '16, 08:51

question was seen: 295 times

last updated: 11 Feb '16, 12:17