Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9749

C# 囲まれた文字列の取り出し

$
0
0
複数行も可能 var bb="{{{aiueo}}}".capture(@"{{{", @"}}}"); //aiueo public static class RegexStringExtension{ public static string capture(this string @this, string head, string tail) { /*usage var aa="(aiueo)".capture(@"\(",@"\)"); //aiueo var bb="{{{aiueo}}}".capture(@"{{{", @"}}}"); //aiueo */ var p = head + "(.*?)" + tail; var ma = Regex.Match(@this, p, RegexOptions.Singleline); if (!ma.Success) return ""; return ma.Groups[1].Value; } }

Viewing all articles
Browse latest Browse all 9749

Trending Articles