How To Split A String After A Particular Character In Jquery
Here is my code : var string1= 'Hello how are =you'; I want a string after '=' i.e. 'you' only from this whole string. Suppose the string will always have one '=' character and i
Solution 1:
Demo Fiddle
Use this : jQuery split(),
var string1= "Hello how are =you";
string1 = string1.split('=')[1];
Split gives you two outputs:
[0]
= "Hello how are "[1]
= "you"
Solution 2:
Try to use String.prototype.substring()
in this context,
var string1= "Hello how are =you";
var result = string1.substring(string1.indexOf('=') + 1);
DEMO
Proof for the Speed in execution while comparing with other answers which uses .split()
Solution 3:
use Split
method to split the string into array
var string1= "Hello how are =you";
alert(string1.split("=")[1]);
Solution 4:
Use .split()
in javascript
var string1= "Hello how are =you";
console.log(string1.split("=")[1]); // returns "you"
Post a Comment for "How To Split A String After A Particular Character In Jquery"