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 7541131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:48:53+00:00 2026-05-30T07:48:53+00:00

I have a lot of text that I need to process for valid URLs.

  • 0

I have a lot of text that I need to process for valid URLs.

The input is vaguely HTMLish, in that it’s mostly html. However, It’s not really valid HTML.

I*ve been trying to do it with regex, and having issues.

Before you say (or possibly scream – I’ve read the other HTML + regex questions) “use a parser“, there is one thing you need to consider:
The files I am working with are about 5 GB in size

I don’t know any parsers that can handle that without failing, or taking days. Furthermore, the fact that, while the text content is largely html, but not necessarily valid html means it would require a very tolerant parser. Lastly, not all links are necessarily in <a> tags (some may be just plaintext).

Given that I don’t really care about document structure, are there any better alternatives WRT extracting links?

Right now I’m using the regex:
\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))) (in grep -E)
but even with that, I gave up after letting it run for about 3 hours.

Are there significant differences in Regex engine performance? I’m using MacOS’s command-line grep. If there are other compatible implementations with better performance, that might be an option.


I don’t care too much about language/platform, though MacOS/command line would be nice.

  • 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-05-30T07:48:54+00:00Added an answer on May 30, 2026 at 7:48 am

    I wound up string a couple grep commands together:

    pv -cN source allContent | grep -oP "(?:\"([^\"' ]*?)\")|(?:'([^\"' ]*?)')|(?:([^\"' ]*?) )" | grep -E "(http)|(www)|(\.com)|(\.net)|(\.to)|(\.cc)|(\.info)|(\.org)" | pv -cN out > extrLinks1

    I used pv to give me a progress indicator.

    grep -oP "(?:\"([^\"' ]*?)\")|(?:'([^\"' ]*?)')|(?:([^\"' ]*?) )"
    Pulls out anything that looks like a word or quoted text, and has no spaces.

    grep -E "(http)|(www)|(\.com)|(\.net)|(\.to)|(\.cc)|(\.info)|(\.org)"
    Filters the output for anything that looks like it could be a URL.

    Finally,
    pv -cN out > extrLinks1
    Outputs it to a file, and gives a nice activity meter.

    I’ll probably push the generated file through sort -u to remove duplicate entries, but I didn’t want to string that on the end because it would add another layer of complexity, and I’m pretty sure that sort will try to buffer the whole file, which could cause a crash.


    Anyways, as it’s running right now, it looks like it’s going to take about 40 minutes. I didn’t know about pv before. It’s a really cool utility!

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

Sidebar

Related Questions

I have a lot of HTML pages that need the same few lines of
I have seemingly a lot of text that i need to get into my
I have hundreds of .doc files with text that I need put on web
I have a large set of real-world text that I need to pull words
I have a log file that contains a lot of text, some of it
I have text files with a lot of uniform rows that I'd like to
I have a complicated background image with a lot of small regions that need
I have a lot of urls that are sadly static, to change them I
I have a project that requires me to process a lot (1000-10000) of big
I have a lot of text data with different structure. I need to extract

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.