C#Regex获取字符串中的第一个字母,无论其大写还是小写 [英] C# Regex getting first letters in a string no matter if its upper or lower case

查看:371
本文介绍了C#Regex获取字符串中的第一个字母,无论其大写还是小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有我肯定有人在这里有一个REGEX,允许挑出第一个字母,然后在那里找到任何其他大写字母。


一个例子是下面:


> supportLevel


它应该捕获 S L


> softwareLicType


它应该捕获 S L
T


> servManagerSubType


它应该捕获 S M S
T


即使它是这样的:


> poc


它应该只捕获 P

解决方案

> > supportLevel

>哪个应该抓住S和L


从技术上讲,它会抓住s和L. 用文字思考: 第一个字符或任何资本:


    ^ |。[A-Z]


Hey all I am sure someone here has a REGEX that allows the first letter to be picked out and then find any other upper case letter there after.

An example is below:

> supportLevel

Which it should catch the S and L.

> softwareLicType

Which it should catch the S, L and T.

> servManagerSubType

Which it should catch the S, M, S and T.

Even if its like this:

> poc

Which it should catch only the P.

解决方案

> >supportLevel
> Which is should catch the S and L

Technically, it would catch the s and L.  Think about it in words:  first char OR any capital:

    ^.|[A-Z]


这篇关于C#Regex获取字符串中的第一个字母,无论其大写还是小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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