我如何...使用Regex从字符串中提取变量名称 [英] How do I... Extract variable names from string with Regex
问题描述
例如,
嗨{$ name},你剩下{$ days}天。
字符串会显示给用户在文本框中,以便在给出执行命令后,他将知道将插入值的位置。如何使用正则表达式或任何其他方法从字符串中提取变量名称:(名称,天)?我正在用C#编程。
提前谢谢。
name},你有{
days}天。
字符串在文本框中显示给用户,以便在给出执行命令后,他将知道值将被插入的位置。如何使用正则表达式或任何其他方法从字符串中提取变量名称:(名称,天)?我正在用C#编程。
提前致谢。
怎么样:(?' parm'\ {[^}] + \})
Hi everybody! I want to read variables names from a given string with regex.
For example,
Hi {$name}, you have {$days} days left.
The string is shown to user in a textbox so that he will know where values will be inserted after giving command for execution. How do I extract the variables names: (name, days) from the string using regex or any other method? I'm programming in C#.
Thanks in advance.
name}, you have {
days} days left.
The string is shown to user in a textbox so that he will know where values will be inserted after giving command for execution. How do I extract the variables names: (name, days) from the string using regex or any other method? I'm programming in C#.
Thanks in advance.
How about : (?'parm'\{[^}]+\})
这篇关于我如何...使用Regex从字符串中提取变量名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!