C# 備忘録

正規表現

正規表現

簡単な正規表現の使い方

Regex r; Match m; public static string HttpUrlRegex = @"(s?https?://[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+)"; public static string sourceHTML = "http://www.google.com/ http://www.yahoo.com/"; r = new Regex( HttpUrlRegex, RegexOptions.IgnoreCase|RegexOptions.Compiled); m = r.Match( sourceHTML ); while( m.Success ) { Console.WriteLine( m.Groups[ 1 ] ); m = m.NextMatch(); } for ( m = r.Match( sourceText ); m.Success; m = m.NextMatch() ) { Console.WriteLine( m.Groups[1] ); }

Home に戻る


Last Updated : 2006-4-15

Copyright © 2006 Mikio Fukushima. All rights reserved.
http://smart-pda.net

Converted by Outliner