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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:03:05+00:00 2026-05-13T20:03:05+00:00

I thought this would be a simple google search but apparently not. What is

  • 0

I thought this would be a simple google search but apparently not. What is a regex I can use in C# to parse out a URL including any query string from a larger text? I have spent lots of time and found lots of examples of ones that don’t include the query string. And I can’t use System.URI, because that assumes you already have the URL… I need to find it in surrounding text.

  • 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-13T20:03:05+00:00Added an answer on May 13, 2026 at 8:03 pm

    This should get just about anything (feel free to add additional protocols):

    @"(https?|ftp|file)\://[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\._~%]*)*"
    

    The real difficulty is finding the end. As is, this pattern relies on finding an invalid character. That would be anything other than letters, numbers, hyphen or period before the end of the domain name, or anything other than those plus forward slash (/), question mark (?), ampersand (&), equals sign (=), semicolon (;), plus sign (+), exclamation point (!), apostrophe/single quote (‘), open/close parentheses, asterisk (*), underscore (_), tilde (~), or percent sign (%) after the domain name.

    Note that this would allow invalid URLs like

    http://../
    

    And it would pick up stuff after a URL, such as in this string:

    Maybe you should try http://www.google.com.

    Where "http://www.google.com." (with the trailing period) would be matched.

    It would also miss URLs that didn’t begin with a protocol specification (specifically, the protocols within the first set of parentheses. For instance, it would miss the URL in this string:

    Maybe you should try http://www.google.com.

    It’s very difficult to get every case without some better-defined boundaries.

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

Sidebar

Related Questions

I thought this would be easy to find, but a google search has been
Just when i thought I had everything figured out .. i got this problem.
I have a relatively simple question that I cant figure out and I cant
I know that this is a popular topic, but I've yet to find an
I want to take the current page's URL (using page:env(caller)) and extract a section
I'm new to python, django and google app engine. All great tools and have
Hey all, I managed to integrate my Database quite well with Excel in the
For example: public class Stereo { public Speaker? LeftSpeaker; public int? Volume; } The
I am trying to allow the user to define a border for an overlay.
Hi I'm new to python. I am trying to add different key value pairs

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.