Sean Lange (4/15/2013)
erikd (4/15/2013)
Sean Lange (4/15/2013)
erikd (4/15/2013)
Really?! There's not an ISALPHA or anything to test for woogy symbols? That's... :unsure:ISAPLHA?? What would you be testing for? Not exactly sure what "woogy symbols" are. 😉
Er... things that aren't letters or numbers.
That would be dependent on a number of things, mostly what language? What is not considered a letter by you may very well be a legitimate letter somebody else that speaks another language. If you mean a-z and 0-9 that is what regex is for.
The rules for setting up a built in function would be far more complicated than a quick test of your own.
English, 95% of the time. I'm not talking about Unicode foreign language characters (finally). I'm mostly talking about ~!@#$%^&*()-_=+[{]}\|;:'",<.>/? and sometimes `. You know, those guys.
I (sort of) get regex, and have a function that I believe I found on here for removing non-alphanumeric characters from strings (let me know if my terminology is wrong; the script was called parsealhpa). But it doesn't do anything other than clean them out. Like, I couldn't use it to just write a query that would find a value containing something outside of the patindex, or include/exclude values based on if they have not-letter-or-number-squiggly-lines in them
I guess I was wondering if there was a more smarterer way of doing things
CREATE FUNCTION [dbo].[ParseAlpha]
(
@string VARCHAR(8000)
)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @IncorrectCharLoc SMALLINT
SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string)
WHILE @IncorrectCharLoc > 0
BEGIN
SET @string = STUFF(@string, @IncorrectCharLoc, 1, '')
SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string)
END
SET @string = @string
RETURN @string
END