I want to extract each part of the following serial code delimitered by dash '-' in separated Regular Expression Extractors in JMeter.
Serial code: cdaf57ce-1a50-42fc-b548-2c84ad7911a8
The expected result is:
Regular Expression Extractor 1: cdaf57ce
Regular Expression Extractor 2: 1a50
Regular Expression Extractor 3: 42fc
Regular Expression Extractor 4: b548
Regular Expression Extractor 5: 2c84ad7911a8
I tried the following regexes for each:
Regular Expression Extractor 1: (\w{8})-
Regular Expression Extractor 2: [^(\w{8})]-(\w{4})-[^(\w{4})]-[^(\w{4})]-[^(\w{12})]
Regular Expression Extractor 3: [^(\w{8})]-[^(\w{4})]-(\w{4})-[^(\w{4})]-[^(\w{12})]
Regular Expression Extractor 4: [^(\w{8})]-[^(\w{4})]-[^(\w{4})]-(\w{4})-[^(\w{12})]
Regular Expression Extractor 5: -(\w{12})
First and last ones worked correctly but others didn't.
Thanks
A simple regex like :
should work fine - and the individual parts can be obtained from the captured groups within the match.
If you must use individual regular expressions for each part then you'd need to do something like
\b[0-9a-f]{8}
(?<=[0-9a-f]{8}-)[0-9a-f]{4}
(?<=[0-9a-f]{8}-[0-9a-f]{4}-)[0-9a-f]{4}
(?<=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-)[0-9a-f]{4}
(?<=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-)[0-9a-f]{12}
this is using a lookbehind, which is not the most efficient construct, (and not supported in all regex engines), but should work. \b matches a word boundary
Lookaheads are another way - and better supported:
[0-9a-f]{8}(?=-)
[0-9a-f]{4}(?=-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b)
[0-9a-f]{4}(?=-[0-9a-f]{4}-[0-9a-f]{12}\b)
[0-9a-f]{4}(?=-[0-9a-f]{12}\b)
[0-9a-f]{12}\b
Try this.This should do it.See demo.
http://regex101.com/r/gJ4uX1/2
Are you using one field to validate this Serial code try this Simple Regex:
Matches:
cdaf57ce-1a50-42fc-b548-2c84ad7911a8
CDAF57CE-1A50-42FC-B548-2C84AD7911A8
12asCda1-23ON-324f-Bse3-htskjas1234q
Regular expression extractor can be used as,
will be the output