正则表达式模式C#匹配一个单词。 [英] Regex Pattern C# to match a word.

查看:350
本文介绍了正则表达式模式C#匹配一个单词。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正则表达式模式(父级):( [Az] {1,}) - ([az] {1,})=>此模式找出(例如:午夜)。

正则表达式模式(子):需要知道用于查找单词(午夜)和(中午)的正则表达式模式。我需要正则表达式来查找这些格式。



从下面的非答案中复制的附加信息(在解决方案1之后)

感谢您的回复。

我有一个单词格式的段落(如下所示)





在我们了解Ed的目标之前,我们无法回答这个问题。如果他的目标是填补所有席位而不必让任何人离开,3美元将是最好的价格。这就是要求的门票数量等于礼堂可用座位数量的价格。然而,对3美元价格的一个可能的反对意见是每部电影都会亏本。总费用为2,200美元,但总收入仅为2,100美元。我们在午夜外出 午夜有大雨。最后午夜非常冷。





您建议找到的模式([Az] {1,})([az] { 1,})所有组合的单词,我只需要从段落中得到午夜(所有突出显示的)单词。类似于空格我也需要使用正则表达式模式单独找到该特定单词。

请给我一个解决方案。



[edit2]缺少粗体添加[/ edit2]

Regex pattern(parent):([A-z]{1,})-([a-z]{1,})=>this pattern finds out(eg:mid-night).
Regex pattern (child):Need to Know regex pattern for finding words(midnight) and (mid night). I need Regex pattern for finding those format.

addtional information copied from non-answer below (after solution 1)
Thanks for your reply.
I am having a paragraph in word format(paragraph shown below)


We can’t answer that question until we know Ed’s objectives. If his aim is to fill all the seats without having to turn anyone away, $3 would be the best price to set. That’s the price at which the quantity of tickets demanded would equal the number of seats available in the auditorium. One possible objection to a $3 price, however, is that each film showing would lose money. Total costs would be $2,200, but total revenue would be only $2,100.we went outside at mid-nightThere was heavy rain at midnight.the last mid night was very cold.


the pattern you suggested finds ([A-z]{1,})([a-z]{1,}) all words which are combined,nut i need to get only the Midnight(all highlighted) word from the paragraph.similarly for space also i need to find that particular word alone using regex pattern.
please provide me a solution.

[edit2]missing bold added[/edit2]

推荐答案

3将是设定的最佳价格。这就是要求的门票数量等于礼堂可用座位数量的价格。然而,对于
3 would be the best price to set. That’s the price at which the quantity of tickets demanded would equal the number of seats available in the auditorium. One possible objection to a


3价格的一个可能的反对意见是每部电影都会亏本。总费用为
3 price, however, is that each film showing would lose money. Total costs would be


2,200,但总收入仅为
2,200, but total revenue would be only


这篇关于正则表达式模式C#匹配一个单词。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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