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

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -