- 58 名前:デフォルトの名無しさん mailto:sage [2012/06/27(水) 23:17:21.48 ]
- URL文字列から次の事をしたいんですけど、
正規表現がどうもまずいみたいです。 また、ループの中でどう <last-string> でグループ化した値を参照したら良いかわかりません。 ご伝授下さい。 string test = "hogehoge.com/123.pdf"; //123.pdf をとりたい //string test = "hogehoge.com/123.html"; 123.html をとりたい //string test = "hogehoge.com/123.doc"; 123.doc をとりたい //string test = "hogehoge.com/"; ""(空文字) をとりたい //string test = "hogehoge.com"; ""(空文字) をとりたい Regex regex = new System.Text.RegularExpressions.Regex(@"^.*\/(?<last-string>[a-zA-Z0-9.].*)$"); MatchCollection matchCol = regex.Matches(test); for(int i = 0; i < matchCol.Count; i++) { //よくわからなん。 //string gotten_string = matchCol[i].Value; }
|

|