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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:51:51+00:00 2026-06-17T08:51:51+00:00

I want to create a regular expression to match a word that begins with

  • 0

I want to create a regular expression to match a word that begins with a period. The word(s) can exist N times in a string. I want to ensure that the word comes up whether it’s at the beginning of a line, the end of a line or somewhere in the middle. The latter part is what I’m having difficulty with.

Here is where I am at so far.

const string pattern = @"(^|(.* ))(?<slickText>\.[a-zA-Z0-9]*)( .*|$)";

public static MatchCollection Find(string input)
{
    Regex regex = new Regex(pattern,RegexOptions.IgnoreCase | RegexOptions.Multiline);
    MatchCollection collection = regex.Matches(input);
    return collection;
}

My test pattern finds .lee and .good. My test pattern fails to find .bruce:

static void Main()
{
    MatchCollection results = ClassName.Find("a short stump .bruce\r\nand .lee a small tree\r\n.good roots");

    foreach (Match item in results)
    {
        GroupCollection groups = item.Groups;
        Console.WriteLine("{0} ", groups["slickText"].Value);

    }
    System.Diagnostics.Debug.Assert(results.Count > 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-17T08:51:52+00:00Added an answer on June 17, 2026 at 8:51 am

    Maybe you’re just looking for \.\w+?

    Test:

    var s = "a short stump .bruce\r\nand .lee a small tree\r\n.good roots";
    Regex.Matches(s, @"\.\w+").Dump();
    

    Result:

    enter image description here

    Note:

    If you don’t want to find foo in some.foo (because there’s no whitespace between some and .foo), you can use (?<=\W|^)\.\w+ instead.

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

Sidebar

Related Questions

I want to create a regular expression that finds the word tjuv (thief in
Can anyone suggest me a solution in Regular Expression, to match a string if
I want to create regular expression for password that has length of atleast 6
I'm trying to create a regular expression that can contain some of those three
I'm trying to create a string from a regular expression. I noticed that in
I just want to create a regular expression out of any possible string. var
I want to create a regular expression that matches input text that starts with
How can I create a regular expression to search strings with a given pattern?
I want to create a regular expression where only numbers are allowed with max
I'm trying to create regular expression that filters from the following partial text: amd64

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.