-1

Possible Duplicate:
What is the best regular expression for validating email addresses?

Hi

How can I find emails with regex ?

"sdafsad@asdfsa.com"
"sdaf-sad@asdfsa.com"
"sdaf-sad@asdfsa.com"
"sdaf-sad@asdf-sa.com"
"sdaf_sad@asdf-sa.com"

Also how can I find this items :

track0; (any track number);
track50 (any track number);
Track 0 (any track number);
Track 10 (any track number);
Track10 (any track number);
Community
  • 1
  • 1
pedram
  • 3,647
  • 6
  • 24
  • 28
  • 1
    try searching the internet: regex lib – Mitch Wheat Aug 02 '10 at 09:56
  • 4
    SO is full of regex questions. Why not search SO before posting another one? – Oded Aug 02 '10 at 09:57
  • Why not learn regular expressions? The ones you're asking for are fairly easy once you know how regular expressions work. http://www.amazon.com/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/1565922573 – Bennor McCarthy Aug 02 '10 at 10:03
  • I found regex for number one (emails). I need number two . – pedram Aug 02 '10 at 10:21
  • what exactly are you trying to match in the second one, do you want the entire string track0; (any track number); just track0; or the track number between the brackets? i.e (any track number) without the brackets()??? – zcourts Aug 07 '10 at 04:04

3 Answers3

1

\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b

found on http://www.regular-expressions.info/email.html

zcourts
  • 4,863
  • 6
  • 49
  • 74
0

1) Straight from Microsoft: How to match a pattern by using regular expressions and Visual C#

using System.Text.RegularExpressions;
Regex emailregex = new Regex("(?<user>[^@]+)@(?<host>.+)");
Match m = emailregex.Match(s);

2) Do you want to validate all entries with that format or do you just want to get that "(any track number)" value?

João Pereira
  • 3,545
  • 7
  • 44
  • 53
0

First one, try searching or use Regular Expression Library

Second, try this:

Regex regex = new Regex(@"[^\d]+\d");