本文介绍了如何使用正则表达式拆分括号内用逗号分隔的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的输入字符串:

message(hello){message = msg.hello;} xyz('Text1','Text2',Text3); asdgfd main.send(msg);



输出:



'Text1'

'Text2'

Text3



我需要从上面的字符串中匹配xyz('Text1','Text2',Text3)并需要获取每个字符串括号内的逗号(,)分隔的单词。任何人都可以给出正确的正则表达式吗?



我尝试过的事情:



我已经尝试但无法正确获取分离的值

解决方案




My Input String :
"message(hello) {message= msg.hello;}xyz('Text1','Text2', Text3);asdgfd main.send(msg);"

Output:

'Text1'
'Text2'
Text3

I need to match "xyz('Text1','Text2', Text3)" from the above string and need to get each word separated by a comma(,) within the bracket. Can anyone give the proper regex to do this?

What I have tried:

I have tried but cannot able to get that separated values properly

解决方案




这篇关于如何使用正则表达式拆分括号内用逗号分隔的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 02:50