Help!!! RegEx.Replace
How do i achieve this directory format using the RegEx.
Input File开发者_开发知识库Name(40 chars) : 000a2d0e62e43b0f680a6eb6019f9671b15ca291
output should looks like this: 00\0a2\d0e\62e43
get only the first 13th character.
Thanks a lot.
johnL
What determines a directory names? The length? What happens to everything else? Assuming the first requires 2 characters, second and third requires 3, the last requires 5 and the rest are thrown out, you could do this:
var str = "000a2d0e62e43b0f680a6eb6019f9671b15ca291";
var pattern = @"^(\w{2})(\w{3})(\w{3})(\w{5})";
var output = Regex.Match(str, pattern).Result(@"$1\$2\$3\$4");
精彩评论