Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex help

Status
Not open for further replies.

xlam

IS-IT--Management
Nov 14, 2007
1
RU
Hi all

I'm newbie in perl and stacked with one regular exression. Im writing some mail parser and want to find mail id.

The header example:
From root@test.com Wed Nov 14 12:35:06 2007
Return-Path: <root@test.com>
X-Original-To: test
Delivered-To: test@test.com
Received: by test.com (Postfix, from userid 0)
id 25CFB1A406C; Wed, 14 Nov 2007 12:35:06
To: test@test.com
Subject: sdsd
Message-Id: <20071114093506.25CFB1A406C@test.com>
Date: Wed, 14 Nov 2007 12:35:06 From: root@test.com (root)

I must extract 25CFB1A406C string.

I can do it with this regexp:
/.*\sid\s(([A-Z]|[0-9]){11}).*/

But as I understood it is simple and can handle unwanted strings.

When I tried to make it more narrow like:
/.*Received:.*\sid\s(([A-Z]|[0-9]){11}).*/

I cant extract mail ID. Can you help me with writing regexp?

Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top