仅拆分句子的第一个匹配项 [英] Split only the first match of a sentence

查看:61
本文介绍了仅拆分句子的第一个匹配项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



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

推荐答案

SwathiSambaraj写道:
SwathiSambaraj wrote:

我需要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!


bujji我知道java .. il tel u ...
bujji i know java.. il tel u ...


这篇关于仅拆分句子的第一个匹配项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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