字符串操作 - 在char的最后一个位置之后获取值 [英] String manipulation - getting value after the last position of a char
本文介绍了字符串操作 - 在char的最后一个位置之后获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在最后一个char(。; + _等)之后获取值:
例如
How I can get the value after last char(. ; + _ etc.): e.g.
string。 name + org.com
string.name+org.com
我想得到com。
jQuery中有没有函数?
I want to get "com". Is there any function in jQuery?
推荐答案
使用 lastIndexOf
和 substr
查找字符并获取字符串后面的部分:
Use lastIndexOf
and substr
to find the character and get the part of the string after it:
var extension = name.substr(name.lastIndexOf(".") + 1);
演示: http://jsfiddle.net/Guffa/K3BWn/
这篇关于字符串操作 - 在char的最后一个位置之后获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文