I'm attempting to create a function that takes in a string and replaces all instances of [alpha character]"
with [alpha character] Inch
. For instance, the string 4" sticker
becomes 4 Inch sticker
, but the string My "Loving" Brother
remains unchanged.
I know I can replace directly using REPLACE(@String, '"', ' Inch')
, but that wouldn't leave the second example unchanged. How can I replace this special character only when the preceding value is an alpha (a-Z) value?
I appreciate any assistance!
4"x2" sticker book
nothing would change? So really, you only want to change the value if it occurs just once? Rule is too open for ambiguity in my book. Maybe... rextester.com/IFC94069 but it only handles 1Case when len(src)-len(replace(src,'"','')) = 1 then replace(src,'"',' Inch ') else src end
– xQbert