0

I'm new in regex and i'm trying to parse the CSS file, to get the:

  • @imports "file.css"
  • url (pathtoFile)

But it fails.

Regex cssUrls = new Regex(@"(url|@import)\((?<char>['""])?(?<url>.*?)\k<char>?\)", RegexOptions.IgnoreCase);

        foreach (Match item in cssUrls.Matches(sData))
        {


            MessageBox.Show(item.Groups[2].Value);


        }

Anyone can help me please ? Thanks in advance!

0

1 Answer 1

0

You can use this pattern:

@import ([""'])(?<url>[^""']+)\1|url\(([""']?)(?<url>[^""')]+)\2\)
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.