Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for regex to split on the string on upper case basis

Tags:

c#

regex

Looking for regex solution for following scenaio:

I have strings, which i have to split on the upper case basis but consecutive uppercase parts should not get split.

For example : if the input is

DisclosureOfComparativeInformation

O/p should be

Disclosure Of Comparative Information

But consecutive uppercase should not get split.

GAAP should not result in G A A P.

How to find the particular pattern and insert space?

Thanx

like image 223
Deepa Avatar asked Sep 22 '11 12:09

Deepa


1 Answers

Try -

var subjectString = "DisclosureOfComparativeInformation";
var resultString = Regex.Replace(subjectString, "([a-z])([A-Z])", "$1 $2");
like image 124
ipr101 Avatar answered Nov 14 '22 21:11

ipr101