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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:15:44+00:00 2026-05-23T00:15:44+00:00

I have a problem dealing with the @ symbol in Regex , I am

  • 0

I have a problem dealing with the @ symbol in Regex, I am trying to remove @sometext
from a text string can’t seem to find anywhere where it uses the @ as a literal. I have tried myself but doesn’t remove the word from the string. Any ideas?

public string removeAtSymbol(string input)
{
    Regex findWords = new Regex(______);//Find the words like "@text"
    Regex[] removeWords;

    string test = input; 
    MatchCollection all = findWords.Matches(test);
    removeWords = new Regex[all.Count];
    int index = 0;
    string[] values = new string[all.Count];

    YesOutputBox.Text = " you got here";

    foreach (Match m in all) //List all the words
    {
        values[index] = m.Value.Trim();
        index++;
        YesOutputBox.Text = YesOutputBox.Text + " " + m.Value;
    }

    for (int i = 0; i < removeWords.Length; i++)
    {
        removeWords[i] = new Regex(" " + values[i]);

        // If the words appears more than one time
        if (removeWords[i].Matches(test).Count > 1)
        {
            removeWords[i] = new Regex(" " + values[i] + " ");
            test = removeWords[i].Replace(test, " "); //Remove the first word.
        }
    }

    return test;
}
  • 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-23T00:15:44+00:00Added an answer on May 23, 2026 at 12:15 am

    You can remove all occurences of "@sometext" from string test via the method

    Regex.Replace(test, "@sometext", "")
    

    or for any word starting with "@" you can use

    Regex.Replace(test, "@\\w+", "")
    

    If you need specifically a separate word (i.e. nothing like @comp within tom@comp.com) you may preceed the regex with a special word boundary (\b does not work here):

    Regex.Replace(test, "(^|\\W)@\\w+", "")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem dealing with EditItemTemplate. What I am trying to do is to
I have a problem dealing with the following construct: SELECT * FROM X INNER
I frequently have problems dealing with DataRows returned from SqlDataAdapters . When I try
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem when I try insert some data to Informix TEXT column via
I have a problem dealing with Generics. Some background: The Animal class is a
I have a big problem dealing with data I try to download in my
I'm using SubSonic 2.2 and sqlite and have encountered a problem when dealing with
I have this problem, which I am dealing with for some time already. At
I know how to approach this problem but i have very little experience dealing

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.