Regular Expression for GUID and How to Test

In a web test, I had to extract the GUID that was part of a dynamically generated input field in ASP.NET. This is a regular expression that matches GUIDs:

[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}

(The (?:…) denotes a non-capturing group.)

To find the right GUID and extract it using a capturing group, I had to use the following expression:

([0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})_txtFirstName

I also found “A better .NET Regular Expression Tester”.

Technorati Tags: ,
Advertisements

One thought on “Regular Expression for GUID and How to Test”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s