[英]mysql remove 2 trailing dots starting at the end of string
How do i remove trailing dots starting from the end of the string.如何删除从字符串末尾开始的尾随点。
I tried a bunch of stuff like TRIM(TRAILING '.' FROM column
) and SUBSTRING but it doesn't fit the desired output due to my column value has a random length.我尝试了一堆诸如 TRIM(TRAILING '.' FROM
column
) 和 SUBSTRING 之类的东西,但由于我的列值具有随机长度,因此它不适合所需的输出。
Here's my sample string:这是我的示例字符串:
"www.facebook.com.102019.crt"
wanted to remove想删除
".102019.crt"
in my string and it should look like this在我的字符串中,它应该是这样的
"www.facebook.com"
Assuming the inputs were always of the form:假设输入始终采用以下形式:
www.domain.com
www.domain.net
You could just use SUBSTRING_INDEX
here:你可以在这里使用
SUBSTRING_INDEX
:
SELECT SUBSTRING_INDEX('www.facebook.com.102019.crt', '.', 3);
This returns:这将返回:
www.facebook.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.