.NET中的正则表达式 [英] Regex in .net

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

问题描述

大家好,
我想知道执行以下操作的具体代码是什么:

将一个字符串拆分为40个正则表达式(我猜是在一个字符串数组中吗?).
循环遍历这40个字符串中的每个字符串,并将THOSE的每个字符串拆分为2个表达式.

任何特定的代码帮助将不胜感激(尤其是在循环部分).提前谢谢.

Suraci

Hello all,
I''m wondering what the specific code would be to do the following:

Split a string into 40 regular expressions (I guess in an array of strings?).
Loop over each of those 40 strings and split each of THOSE into 2 expressions.

Any specific code help would be appreciated (especially on the looping parts). Thanks in advance.

Suraci

推荐答案

听起来您根本不需要正则表达式.通常,您将使用正则表达式执行搜索,匹配或选择已定义的正则表达式模式,但实际情况并非如此.要拆分字符串,您只需使用String.Split.

将逗号分隔的值拆分为字符串数组:
string [] words = s.Split('','');

然后,您可以根据需要在数组中再次拆分这些字符串.这非常简单,无需为此使用任何正则表达式.

祝你好运!
It sounds like you don''t need regex at all. Normally you would use regex to perform searching, matching or selecting of defined regex patterns but that isn''t the case here. To split strings you can simply use String.Split.

Split comma separated values to an array of strings:
string[] words = s.Split('','');

You could then split those strings in the array again if needed. This is very simple and no need to use any regex for that.

Good luck!


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

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