Help with Regular Expressions

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

In the process of monitoring my inbox with .NET code, I
would like to check the body of the email message to
determine if there is a code (GUID) stored in the body of
the mail message formatted like the code below. The
position of the code may or may not be the last thing in
the body of the email message. The code will be stored in
the email body like this:

Attn: Recipient Name,

This letter is to inform you of ........
blah, blah, blah....
blah, blah, blah....

sincerely,
Sender Name

CODE:0c3f4121-8ed9-4815-9ce6-248c3d206c86

I need help creating a regular expression that will
determine if the email body has a code in it and if it
does, then strip out only the GUID from it so I can then
further process the information from the email.

Thanks.
 
-----Original Message-----
In the process of monitoring my inbox with .NET code, I
would like to check the body of the email message to
determine if there is a code (GUID) stored in the body of
the mail message formatted like the code below. The
position of the code may or may not be the last thing in
the body of the email message. The code will be stored in
the email body like this:

Attn: Recipient Name,

This letter is to inform you of ........
blah, blah, blah....
blah, blah, blah....

sincerely,
Sender Name

CODE:0c3f4121-8ed9-4815-9ce6-248c3d206c86

I need help creating a regular expression that will
determine if the email body has a code in it and if it
does, then strip out only the GUID from it so I can then
further process the information from the email.

Thanks.
.

Ok, I found an answer for this. It is the following RegEx:

[\da-z]{8}(-)[\da-z]{4}(-)[\da-z]{4}(-)[\da-z]{4}(-)[\da-z]
{12}
 
Brian,
Ok, I found an answer for this. It is the following RegEx:

[\da-z]{8}(-)[\da-z]{4}(-)[\da-z]{4}(-)[\da-z]{4}(-)[\da-z]
{12}

I think you want to use [\da-f] rather than [\da-z], since the g-z
aren't legal hexadecimal characters.



Mattias
 
Back
Top