Witam. Mam sobie dlugiego stringa, i chce w nim poszukac wystapienia jakiegos regexa. Chcialbym iterowac jakos przez ten string i zwracac kolejne wystapienia podciagu spelniajacego regex. Czy ktos moglby mi pokazac jak sie takie cos robi w C#? Chodzi mi o zasade i klasy, regexa zloze sam :-) Wielkie dzieki!
0
0
Tu masz przyklad zapisujacy linki z html'a do pliku:
using System.Text.RegularExpressions;
...
Regex vRegex = new Regex(@"(?i)<a[^>]+href\s*=['""]?(?)?([^>'""])['""]?\s[^>]>([^>])<\s*/a\s*>");
MatchCollection vResult = vRegex.Matches(html);
foreach(Match vMatch in vResult)
if(vMatch.Groups[1] != null && vMatch.Groups[2] != null)
{
vContents = System.Text.Encoding.Default.GetBytes("""+vMatch.Groups[2].Value+"",""+vMatch.Groups[1].Value+""\n");
vFileStream.Write(vContents, 0, vContents.Length);
}
pozdrawiam
johny