c# - Why does this Regular Expression match nothing? -


i want replace instances of consecutive non-lowercase-alphabet-letters single space each instance. works, why inject spaces in between alphabet letters?

const string pattern = @"[^a-z]*"; const string replacement = @" "; var reg = new regex(pattern);  string = "the --fat- cat"; string b = reg.replace(a, replacement);  // b = " t h e  f t  c t " should "the fat cat" 

because of *(which repeats previous token zero or more times). must finds match in boundaries since empty string exists in boundaries.

const string pattern = @"[^a-z]+"; 

Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -