0

I have a column of type varchar containing chars and numbers. Ex: "ABC123", "XY2"

I want to find the substring before a number. Output:"ABC", "XY"

I went through this post Finding number position in string. But it looked tedious. Is there any elegant way to do this?

I tried to use Locate() as in this post MySQL: Use REGEX to extract string (select REGEX), but it does not take regexp.

Community
  • 1
  • 1
Krishna Chaitanya
  • 275
  • 1
  • 2
  • 9
  • Unfortunately, MySQL doesn't have any good built-in functions for doing this. The method in the the first question you linked to is as good as it gets. If you want something less verbose, write a UDF. – Barmar Feb 26 '16 at 20:52
  • Thanks. I am left with no choice then. – Krishna Chaitanya Feb 26 '16 at 20:59
  • it can be achieved by MySQL 'user' function or, at least, you can extract a string without digits by means of backend script – RomanPerekhrest Feb 26 '16 at 21:47

0 Answers0