问题描述
Hi,
rules = "(The(code(project)))";
var parent = rules.split("(");
split函数将所有用("一个大括号分隔的单词分开,并将所有单词存储在一个数组中...
array = [The,code,project)))]
它以上述方式存储.
我需要Split函数将第一个单词(即"The"分解为1个单词,将"code(project)))"分解为另一个单词..
用Javascript可以吗?
请让我知道..
在此先感谢
问候,
Swathi
The split function splits all the words separated by "(" an open brace and stores all the words in an array,..
array = [The,code,project)))]
it stores in the above fashion.
I need the Split function to split only the first word i.e "The" into 1 word and "code(project)))" into other word..
Is it possible in Javascript?
Please let me know..
Thanks in advance
Regards,
Swathi
推荐答案
我需要Split函数来仅拆分第一个单词,即"The"变成一个单词,"code(project)))"变成另一个单词.
可以用Javascript吗?
I need the Split function to split only the first word i.e "The" into 1 word and "code(project)))" into other word..
Is it possible in Javascript?
是的!
您需要自定义操作,因此您将无法使用标准方法(如split或类似方法).只需显式声明一个变量,在前两个大括号之间找到单词,然后将其存储在数组第0个位置,并将第二个括号后的文本存储在第1个位置.完成!
Yes!
You need a custom action so you won''t be able to use standard methods lke split or so. Just explicitly declare a variable, find the word between first two braces and store that in arrays 0th position and the text after second brace into 1st position. Done!
这篇关于仅拆分句子的第一个匹配项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!