jeudi 24 décembre 2015

Changing RegEx pattern during the using of program from textBox

I just need to know, how to change RegEx pattern during the using of program. I mean. Changing of pattern from text Box, I was trying, but, I cannot find the answer. Simple string value doesn't work, then I really don't know what...

public class LinkExtractor
    {
        public static List<string> Extract(string html)
        {
            List<string> list = new List<string>();
            Regex regex = new Regex("(?:href|src)=[\"|']?(.*?)[\"|'|>]+", RegexOptions.Singleline | RegexOptions.CultureInvariant);
            if (regex.IsMatch(html))
            {
                foreach (Match match in regex.Matches(html))
                {
                    list.Add(match.Groups[1].Value);
                }
            }

            return list;
        }
    }

Aucun commentaire:

Enregistrer un commentaire