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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:20:23+00:00 2026-06-03T20:20:23+00:00

I need a regex which will do the following Extract all strings which starts

  • 0

I need a regex which will do the following

Extract all strings which starts with http://
Extract all strings which starts with www.

So i need to extract these 2.

For example there is this given string text below

house home go www.monstermmorpg.com nice hospital http://www.monstermmorpg.com this is incorrect url http://www.monstermmorpg.commerged continue

So from the given above string i will get

    www.monstermmorpg.com
http://www.monstermmorpg.com
http://www.monstermmorpg.commerged

Looking for regex or another way. Thank you.

C# 4.0

  • 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-03T20:20:26+00:00Added an answer on June 3, 2026 at 8:20 pm

    You can write some pretty simple regular expressions to handle this, or go via more traditional string splitting + LINQ methodology.

    Regex

    var linkParser = new Regex(@"\b(?:https?://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
    var rawString = "house home go www.monstermmorpg.com nice hospital http://www.monstermmorpg.com this is incorrect url http://www.monstermmorpg.commerged continue";
    foreach(Match m in linkParser.Matches(rawString))
        MessageBox.Show(m.Value);
    

    Explanation
    Pattern:

    \b       -matches a word boundary (spaces, periods..etc)
    (?:      -define the beginning of a group, the ?: specifies not to capture the data within this group.
    https?://  - Match http or https (the '?' after the "s" makes it optional)
    |        -OR
    www\.    -literal string, match www. (the \. means a literal ".")
    )        -end group
    \S+      -match a series of non-whitespace characters.
    \b       -match the closing word boundary.
    

    Basically the pattern looks for strings that start with http:// OR https:// OR www. (?:https?://|www\.) and then matches all the characters up to the next whitespace.

    Traditional String Options

    var rawString = "house home go www.monstermmorpg.com nice hospital http://www.monstermmorpg.com this is incorrect url http://www.monstermmorpg.commerged continue";
    var links = rawString.Split("\t\n ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Where(s => s.StartsWith("http://") || s.StartsWith("www.") || s.StartsWith("https://"));
    foreach (string s in links)
        MessageBox.Show(s);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a regex that will give me the following results from each example
I need to make regex which will capture the following: Fixed unicode text: <br>
Can anyone help me with this regex? I need something which will ALLOW: 0-9
I need a regex pattern which will accommodate for the following. I get a
I need a regex to run against strings like the one below that will
I need a regex that will match strings of letters that do not contain
I need a regex which will allow only A-Z, a-z, 0-9, the _ character,
i was in need of a regex which will return only 25,36,30 for me
I just need to verify that this regex statement will do what I want.
Basically I need a regex which will return true if the string is a

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.