• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 579
  • Last Modified:

RegEx - parse string after @ symbol

I have the following string:
@expertsexchange and @[14] trying to figure out regex

In C# I want to capture both the "expertsexchange" and "14".  I made the following RegEx codes for both, but how do I combine both into one statement and then get the values?

1: @\[(\d+)\]
2: [@](\w+)
2 Solutions
Fernando SotoRetiredCommented:
Hi Latitude34;

Try the pattern like this.

string pattern = @"(@\[(\d+)\])|(@\w+)";

Open in new window

Try -


Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now