如何在jquery中的特定字符之后拆分字符串 [英] How to split a string after a particular character in jquery
本文介绍了如何在jquery中的特定字符之后拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
var string1= "Hello how are =you";
我想在=之后输入一个字符串,即只有整个字符串中的你。假设字符串将始终具有一个=字符,并且我想要在jquery中的新变量中该字符之后的所有字符串。
I want a string after "=" i.e. "you" only from this whole string. Suppose the string will always have one "=" character and i want all the string after that character in a new variable in jquery.
请帮助我。
推荐答案
演示小提琴
使用此:jQuery split() ,
Demo Fiddle
Use this : jQuery split(),
var string1= "Hello how are =you";
string1 = string1.split('=')[1];
Split为您提供两个输出:
Split gives you two outputs:
-
[0]
=你好怎么样
[1]
=你
这篇关于如何在jquery中的特定字符之后拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文