question

SakeriyeMohamud-4520 avatar image
0 Votes"
SakeriyeMohamud-4520 asked Givary-MSFT commented

Guid Regex help on validate pattern

hi i would like some help to validate a pattern before releases the regex is correct but not entirely what im looking for

this is the regex I want however, im looking for it be exact, meaning it has start always with 8 and end with 12. as \w means any digit

Regex: \w{8}-\w{4}-\w{4}-\w{4}-\w{12}

so I can validate the pattern below with it exactly:
ddd30904-6845-4ca6-84d6-9c9a75756e76
66211f6b-e2f5-926a-4f45-b7aaff8262a9
7f14135e-c257-44cd-b76c-28e7c4aa90d0
400382fa-f551-41a6-b2e2-ab4d719fdf57


what would the new regex be?

azure-ad-passwordless-authentication
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Givary-MSFT avatar image
0 Votes"
Givary-MSFT answered Givary-MSFT commented

@SakeriyeMohamud-4520 Thank you for reaching out to us.

I have tested your above regex \w{8}-\w{4}-\w{4}-\w{4}-\w{12} with the one of guid provided in the question, however it works but if i add any extra character to the guid, it doesnt give desired results as expected.

Then researched and found the following regex ^[a-f0-9]{8}-([a-f0-9]{4}-){3}[a-f0-9]{12}$ and tested with the one of the guid in the question, it works as expected. i have tested by adding extra character to one of the set in the guid to verify the results, below is the screenshot for your reference.

190910-image.png



If you want to use the same regex \w{8}-\w{4}-\w{4}-\w{4}-\w{12} with the guid mentioned in the question, i need to check how this regex ( give me day's time ) if it can be tweaked to meet the desired results correctly.

Let me know if you have any questions.

Please remember to "Accept Answer" if answer/reply helped, so that others in the community facing similar issues can easily find the solution.





image.png (21.5 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @GirishVaryani by anychance would you happen to have the answer for

"If you want to use the same regex \w{8}-\w{4}-\w{4}-\w{4}-\w{12} with the guid mentioned in the question, i need to check how this regex ( give me day's time ) if it can be tweaked to meet the desired results correctly"

0 Votes 0 ·
Givary-MSFT avatar image Givary-MSFT SakeriyeMohamud-4520 ·

@SakeriyeMohamud-4520

Apologies for the delay, Please find this regex which meets your criteria

"66211f6b-e2f5-926a-4f45-b7aaff8262a9" -match '^[\w]{8}-([\w]{4}-){3}[\w]{12}$'

191461-image.png



Let me know if you have any questions.

0 Votes 0 ·
image.png (19.5 KiB)