Split a string with '[' and ']'
本文关键字:and Split string with | 更新日期: 2023-09-27 18:15:25
我想知道一个包含[
和]
的字符串的RegEx分割模式(使用c#)。
例如,对于字符串:
This is my [word1] And this is my [word2]
我应该得到word1
和word2
可以这样做:
'[(?<word>[^']]*)']
我建议你使用一些正则表达式工具来帮助你。我肯定有一些,但我用Expresso,它真的帮助这些讨厌的事情:)
使用regex /'[(.*?)']/g
。如果正则表达式是在perl中,那么在其他语言中也是如此。在这里工作:https://regex101.com/r/zL0yW1/1