Reputation: 96
I have searched Google and still don't know how to write a regular expression for this:
rec-1-20151103142759-d9fd57bc-4fe3-4b91-a640-ddd54ef081dd-Speakers-Andreea.Dumitru-ANDREEADUM-DSK-9fa377fe-3290-4cb7-9c7e-6ea86e01e08f-1066
What I have to obtain from this string is the following:
I have started with
Regex regex = new Regex(-[0-9]{1}(| |-)[0-9]{14}(| |-)[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}(| |-)[a-fA-F](| |-)[a-fA-F](| |-) ....
Upvotes: 1
Views: 71
Reputation: 2593
Here is a solution:
\w{3}-(\d)-(\d{14})-([\w\d]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12})-(\w+)-([\w.]+)-(\w+-\w+)-([\w\d]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12}-[\w\d]{4})
This would be the line in C# without regex options:
Regex regex = new Regex(@"\w{3}-(\d)-(\d{14})-([\w\d]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12})-(\w+)-([\w.]+)-(\w+-\w+)-([\w\d]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12}-[\w\d]{4})");
Here it is in regex101: https://regex101.com/r/bI8yH6/1
Upvotes: 3