I have a table MY_TBL
with a varchar field MY_FLD
. I need to find rows where MY_FLD
contains a number followed by a hyphen followed by a number (typically a range).
The following lines should be selected:
fffff 1-5 fdsfdsfds
1-5 fdsfdsfds
aaaa 10-23
1-50 fdsfdsfds
and these should not:
-5 dsgdgf
10- rere
-15
10 -23
10- 23
The regex for the number-hyphen-number pattern is \d+\-\d+
.
How do I use it in a MySql statement? Is it possible to extract the pattern into a separate string?
fffff 1-5 fdsfdsfds -> 1-5
1-5 fdsfdsfds -> 1-5
aaaa 10-23 -> 10-23
1-50 fdsfdsfds -> 1-50