2PTTechnology

The platform that enables you to build rich, interactive communities
Welcome to 2PTTechnology Sign in | Join | Help
in Search

Find the locatioin of a non alphanumeric character

Last post 02-05-2009, 12:01 PM by twaligora. 0 replies.
Sort Posts: Previous Next
  •  02-05-2009, 12:01 PM 201

    Find the locatioin of a non alphanumeric character

    declare @value varchar(50)

    set @value = '1002902109CC-5350-7344'

    select

    patindex('%[^a-zA-Z0-9 ]%', @value) as LocationOfNonAlphaNumeric,

    substring(@value, 1, patindex('%[^a-zA-Z0-9 ]%', @value) - 1) ,

    substring(replace(@value, substring(@value, 1, patindex('%[^a-zA-Z0-9 ]%', @value)), ''),1,patindex('%[^a-zA-Z0-9 ]%', replace(@value, substring(@value, 1, patindex('%[^a-zA-Z0-9 ]%', @value)), '')) - 1),

    replace(replace(@value, substring(@value, 1, patindex('%[^a-zA-Z0-9 ]%', @value)), ''),substring(replace(@value, substring(@value, 1, patindex('%[^a-zA-Z0-9 ]%', @value)), ''),1,patindex('%[^a-zA-Z0-9 ]%', replace(@value, substring(@value, 1, patindex('%[^a-zA-Z0-9 ]%', @value)), '')) ),''),

    @value

     

View as RSS news feed in XML
Powered by Community Server (Personal Edition), by Telligent Systems