文本文件中[* anytext *]的正则表达式。帮助plzz [英] regex for [*anytext*] in a text file. help plzz

查看:198
本文介绍了文本文件中[* anytext *]的正则表达式。帮助plzz的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在文本文件中找到[* anytext *]的模式匹配。

示例

这是一个包含所有列表的自动电子邮件昨天启动的服务([*昨天*])。请注意,对齐结算的天数将是< b> [* DaysToAlignBilling *]。< / b> < br />< br /> .......

我需要从这个文件中提取所有[* .... *]标签。

任何帮助高度赞赏

解决方案

试试这种模式:@" \ [\ *。*?\ * \]"

这与开始和结束相匹配"[*" " *]"模式并以非贪婪的方式捕捉它们之间的任何角色。这是一个例子:


















string test = "这是一封自动发送的电子邮件.. ([* *昨天])。请注意......< b> [* DaysToAlignBilling *]。< / b>" ;
foreach (匹配m Regex.Matches(test,@ " \ [\\ \\ *。*?\ * \]" ))
{
Console.WriteLine(m.Value);
}

Hi, I need to find the pattern match for [*anytext*] in a text file.

example

This is an automated email containing a list of all services activated yesterday ([*Yesterday*]). Please note that the number of days to align billing will be <b>[*DaysToAlignBilling*].</b> <br/><br/>.......

I need to extract all the [*.... *] tags from this file.

Any help highly appreciated

解决方案

Try this pattern: @"\[\*.*?\*\]"

This matches the opening and closing "[*" "*]" pattern and captures any character in between them in a non-greedy fashion. Here's an example:

string test = "This is an automated email ... ([*Yesterday*]). Please note that ... <b>[*DaysToAlignBilling*].</b>";  
 
foreach (Match m in Regex.Matches(test, @"\[\*.*?\*\]"))  
{  
    Console.WriteLine(m.Value);  


这篇关于文本文件中[* anytext *]的正则表达式。帮助plzz的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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