alphanumeric

How to remove all non-alpha numeric characters from a string in MySQL?

≡放荡痞女 提交于 2019-11-26 03:40:03
问题 I\'m working on a routine that compares strings, but for better efficiency I need to remove all characters that are not letters or numbers. I\'m using multiple REPLACE functions now, but maybe there is a faster and nicer solution ? 回答1: None of these answers worked for me. I had to create my own function called alphanum which stripped the chars for me: DROP FUNCTION IF EXISTS alphanum; DELIMITER | CREATE FUNCTION alphanum( str CHAR(255) ) RETURNS CHAR(255) DETERMINISTIC BEGIN DECLARE i, len

How to generate a random alpha-numeric string?

狂风中的少年 提交于 2019-11-25 22:55:51
问题 I\'ve been looking for a simple Java algorithm to generate a pseudo-random alpha-numeric string. In my situation it would be used as a unique session/key identifier that would \"likely\" be unique over 500K+ generation (my needs don\'t really require anything much more sophisticated). Ideally, I would be able to specify a length depending on my uniqueness needs. For example, a generated string of length 12 might look something like \"AEYGF7K0DM1X\" . 回答1: Algorithm To generate a random string

How to strip all non-alphabetic characters from string in SQL Server?

女生的网名这么多〃 提交于 2019-11-25 22:25:08
问题 How could you remove all characters that are not alphabetic from a string? What about non-alphanumeric? Does this have to be a custom function or are there also more generalizable solutions? 回答1: Try this function: Create Function [dbo].[RemoveNonAlphaCharacters](@Temp VarChar(1000)) Returns VarChar(1000) AS Begin Declare @KeepValues as varchar(50) Set @KeepValues = '%[^a-z]%' While PatIndex(@KeepValues, @Temp) > 0 Set @Temp = Stuff(@Temp, PatIndex(@KeepValues, @Temp), 1, '') Return @Temp End