Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8150129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:59:24+00:00 2026-06-06T14:59:24+00:00

Following on from a post I made earlier, I am making progress with what

  • 0

Following on from a post I made earlier, I am making progress with what I require, but not knowing much about how RegEx expressions work, I’m stuck!

This line:

FilesM = Regex.Matches(StrFile, "<link.*?href=""(.*?)"".*? />")

Is extracting from the HTML of my page, all <link.. elements to compile a combined style file.

However, I need to exclude any media="print" links.

I am also trying to combine JS scripts

FilesM1 = Regex.Matches(StrFile, "<script.*?src=""(.*?)"".*?></script>")

Does this, but in this case, I want to exclude any scripts which are not hosted locally. I’d like to do this by excluding any scripts where the href starts with “http”

So how would I exclude these two cases from the match collection?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:59:26+00:00Added an answer on June 6, 2026 at 2:59 pm

    I know this isn’t exactly what you are looking for, but, in case you are interested, here’s an example of how to find just the elements you care about using XPath:

    Dim doc As New XmlDocument()
    doc.LoadXml(html)
    Dim linkNodes As XmlNodeList = doc.SelectNodes("descendant-or-self::link[(@href) and (not(@media) or (@media != 'print'))]")
    Dim scriptNodes As XmlNodeList = doc.SelectNodes("descendant-or-self::script[(@src) and (not(starts-with(@src,'http')))]")
    

    The XmlDocument.SelectNodes method returns all elements that match the given XPath.

    In the XPath string, descendant-or-self:: means you want it to search all elements from the current position (the root) down through all descendants for the following element name. If that was left out, it would only look for matching elements at the current (root) level.

    The [] clauses provide conditions. So for instance, link[@media != 'print'] would match all link elements that don’t have a media attribute that equals “print”. The @ sign specifies an attribute name.

    Simply listing an attribute name by itself in a condition means that you are checking for the existence of that attribute. For instance, link[@href] matches all link elements that do have an href attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following on from my other post about primary keys I am wondering if there
I am using the following code to post data from an android app to
I have made the following search script but can only search one table column
** MAJOR UPDATE ** I made a minor mistake but I'm still curious about
In the following link within the 4th image from the top: http://duartes.org/gustavo/blog/post/page-cache-the-affair-between-memory-and-files The scenario
The following ajax call, made from a checkbox, somehow fails in Internet explorer, while
The following code shows the posts made the last 30 days. Every post I
Following from my last question which @Jon Skeet gave me a lot of help
Following from these question Subset sum problem and Sum-subset with a fixed subset size
Is the following From header incorect? // To send HTML mail, the Content-type header

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.