Utilisez substring() ou slice()
Fonction : split()
Fonction : utiliser un délimiteur spécifié pour diviser et stocker une chaîne dans un tableau
exemple:
Copiez le code comme suit :
str=”jpg|bmp|gif|ico|png”;
arr=theString.split(”|”);
//arr est un tableau contenant les valeurs de caractères "jpg", "bmp", "gif", "ico" et "png"
Fonction : Jean()
Fonction : Combinez un tableau en une chaîne en utilisant un délimiteur de votre choix
exemple:
Copiez le code comme suit :
var delimitedString=myArray.join(delimiter);
var maListe=new Array("jpg","bmp","gif","ico","png");
var portableList=myList.join(”|”);
//Le résultat est jpg|bmp|gif|ico|png
Fonction : sous-chaîne()
Fonction : Interception de chaîne Par exemple, si vous souhaitez obtenir « Minidx » à partir de « MinidxSearchEngine », vous devez utiliser substring(0,6)
Fonction : indexOf()
Fonction : renvoie l'indice du premier caractère correspondant à la sous-chaîne dans la chaîne
Copiez le code comme suit :
var maChaîne=”JavaScript”;
var w=myString.indexOf(”v”);w sera 2
var x=myString.indexOf(”S”);x sera 4
var y=myString.indexOf(”Script”);y sera également 4
var z=myString.indexOf("key");z sera -1