如何在特定字符之前替换字符串的子字符串?

编程入门 行业动态 更新时间:2024-10-28 10:32:18
本文介绍了如何在特定字符之前替换字符串的子字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

表格电子邮件:

值:

josh@yahoo carmine32@hotmail zehmaneh@yahoo

我想用 test 替换 @ 之前的字符串.

I want to replace the string before @ with test.

结果:

test@yahoo test@hotmail test@yahoo

如何使用子串并根据字符串中的字符进行替换?

How do I use substringing and replace based on a character in the string?

推荐答案

你甚至不需要使用substring或replace,你可以使用这个:>

You don't even need to use substring or replace, you can use this:

SELECT 'test' + RIGHT(email, charindex('@', REVERSE(email))) FROM YourTable

你可以用这个来测试一下:

You can test it out with this:

DECLARE @email nvarchar(50) SET @email = 'carmine32@hotmail' PRINT 'test' + RIGHT(@email, charindex('@', REVERSE(@email)))

更多推荐

如何在特定字符之前替换字符串的子字符串?

本文发布于:2023-10-16 17:08:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498203.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   字符   在特定

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!