Hello,
i am trying to search a number 1-5 in a long text field.
I am using PATINDEX function and regular expression.
here is my example:
Declare @mystr varchar (50)
set @mystr = 'closing in 5 days'
Select substring(@mystr,patindex ('%[1-5]%'),@mystr),1) =' '
if text like
'closing in 5days' or 'closing in5 days'
then i would like to catch it but i dont want to catch text like
'closing in 15 days'
Select substring(@mystr,patindex ('%[1-5]%'),@mystr),1) =' '
this script will catch if the text contain 'closing in 5 days' or 'closing in5 days' but it would not catch 'closing in 5days' because after 5 there is a alfanumeric character.
Is there way to use Patindex and regular expression to solve this problem.
Note I need to use this script in sql function then i believe i cannot use regex.
Any help greatly appriciated.
thx
i am trying to search a number 1-5 in a long text field.
I am using PATINDEX function and regular expression.
here is my example:
Declare @mystr varchar (50)
set @mystr = 'closing in 5 days'
Select substring(@mystr,patindex ('%[1-5]%'),@mystr),1) =' '
if text like
'closing in 5days' or 'closing in5 days'
then i would like to catch it but i dont want to catch text like
'closing in 15 days'
Select substring(@mystr,patindex ('%[1-5]%'),@mystr),1) =' '
this script will catch if the text contain 'closing in 5 days' or 'closing in5 days' but it would not catch 'closing in 5days' because after 5 there is a alfanumeric character.
Is there way to use Patindex and regular expression to solve this problem.
Note I need to use this script in sql function then i believe i cannot use regex.
Any help greatly appriciated.
thx