Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
Regular Expression to extract strings between angle brackets with exactly one @ char in between

Does any one have an idea how to match something like

<t@t.com>

I tried this regular expression

\<(.?*)\>

but this matches also <sddsds> I want it to match where inside <> is an email with @ sign.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can use

<([^<>@]+@[^<>@]+)>

See the regex demo. Details:

  • < - a < char
  • ([^<>@]+@[^<>@]+) - Group 1: any one or more chars other than <, > and @, a @ char and then again any one or more chars other than <, > and @
  • > - a > char.

See the PHP demo:

$str = "<t@t.com>\n<tatacom>\n<t@ata@com>";
$re = '/<([^<>@]+@[^<>@]+)>/';
if (preg_match_all($re, $str, $matches)) {
    print_r($matches[1]);
}
// => Array( [0] => t@t.com )
over 4 years ago · Santiago Trujillo Report

0

You can use this:

$regex = '/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/'

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!