我想用jquery分割一个字符串 [英] I want to split a string using jquery

查看:91
本文介绍了我想用jquery分割一个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var value = {Name:〜/ Doccument / YourDirectory / abcd / Contacts}

var newList = value.split(/);





i希望分割价值然后我怎么做。



我尝试过:



i尝试拆分但发生错误,因为字符串不是正确的。名称:那么我怎么办?

解决方案

看起来值是JSON数组?根据此处提供的内容,您可以更改代码以通过value.Name访问Name值,然后调用split函数。见下文



<前lang =Javascript> var value = {姓名: 〜/ Doccument / YourDirectory / abcd / Contacts};


(< span class =code-string> #b)。html( 原文: + value.Name);
var lines = value.Name.split(' /');


#r )。html( Splited: + lines);


var value = {Name: "~/Doccument/YourDirectory/abcd/Contacts"}
var newList = value.split("/");


i want to split value then how i can do that.

What I have tried:

i tried split but an error occured because string is not a correct from."Name:" is also there then how i do?

解决方案

Look like the value is JSON Array? Based on what presented here, you can change the code to access the Name value through value.Name, and then call the split function. See below

var value = {Name: "~/Doccument/YourDirectory/abcd/Contacts"};


("#b").html("Original :" + value.Name); var lines = value.Name.split('/');


("#r").html("Splited :" + lines);


这篇关于我想用jquery分割一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆