如何在第二个资本出现之前捕获文本 [英] How do I capture the text before the second capital appears

查看:58
本文介绍了如何在第二个资本出现之前捕获文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述













HyderabadProduct Development,设计自己的设计并开发网站。框架:Magento:Drupal,Joomla,Ruby on Rails,Codeigniter(任何一个或组合)。擅长Sql数据库。看。











从上面的文字我想只捕获数据Hyderabad即,我想删除第二个大写使用正则表达式时出现的文本

解决方案

正则表达式正则表达式= 正则表达式( @  ^(? <部分> [AZ] [AZ] +)[AZ]); 

匹配m = regex.Match( @ HyderabadProduct Development,设计自己的设计并开发框架:Magento:Drupal,Joomla,Ruby on Rails,Codeigniter(任何一个或组合)。良好的Sql数据库。看。);

if (m.Success)
{
string wantedPart = m.Groups [ part]。
}


如果仅在第二个资本之前都是字母:

(?= (^ [AZ] [AZ] *))


Hi,





HyderabadProduct Development, Design his own designs and developed the websites. Framework: Magento: Drupal, Joomla, Ruby on Rails , Codeigniter (any one or a combination). Good in Sql Database. Looking.





From the above text i want to capture data only Hyderabad i.e, i want to remove the text when second capital appears using regular expression

解决方案

Regex regex = new Regex(@"^(?<part>[A-Z][a-z]+)[A-Z]");

Match m = regex.Match(@"HyderabadProduct Development, Design his own designs and developed the websites. Framework: Magento: Drupal, Joomla, Ruby on Rails , Codeigniter (any one or a combination). Good in Sql Database. Looking.");

if (m.Success)
{
   string wantedPart = m.Groups["part"].Value;
}


If all are alphabets only before the 2nd capital:

(?=(^[A-Z][a-z]*))


这篇关于如何在第二个资本出现之前捕获文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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