Author |
Topic |
jrockfl
Posting Yak Master
223 Posts |
Posted - 2007-11-12 : 11:19:09
|
I was looking at this article, and it is close to what I need. http://sqlteam.com/forums/topic.asp?TOPIC_ID=27205I need a function that returns that match, and does not replace it.I pass in the RegEx pattern and it would return the matching text.ie. my patern is [A-Za-z]and it would return the match from the column. Make sense? |
|
anonymous1
Posting Yak Master
185 Posts |
Posted - 2007-11-12 : 11:29:40
|
you looked at the proc in that post named dbo.regexFind, and it is not what you are looking for? |
|
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2007-11-12 : 12:00:03
|
No, becuase it returns bit if it finds a match or not. I would like to return the matched string |
|
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2007-11-12 : 12:04:44
|
regexReplace is close, but i do not want to replace, i want to return the matches |
|
|
anonymous1
Posting Yak Master
185 Posts |
Posted - 2007-11-12 : 12:28:53
|
you should just need to create your own wrapper...CREATE FUNCTION dbo.regexFound(@source varchar(5000),@regexp varchar(1000),@ignoreCase bit = 0)RETURNS varchar(5000) ASbegin declare @found bit set @found = dbo.regexFind(@source, @regexp, @ignoreCase) RETURN CASE WHEN @found = 1 THEN @source ELSE NULL ENDend |
|
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2007-11-12 : 12:36:43
|
Thank you for help, but that returns the orginal text in the column without the regex applied |
|
|
anonymous1
Posting Yak Master
185 Posts |
Posted - 2007-11-12 : 12:48:51
|
not sure what you mean by applied. please post your inputs and outputs. |
|
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2007-11-12 : 13:42:47
|
I created a regex to return just the model name of a house. I have this value in the column "The Remington Elevation A""Remington" would be returned. This is my desired result. Afer I apply dbo.regexReplace, my result now looks like "The Elevation A"My matched text of "Remington" is now replaced with '' |
|
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2007-11-12 : 15:03:29
|
Thanks for your help, I rewrote my regex to match the opposite of what I had originally matched, now that replace function works the way i needed. |
|
|
|