This is the example:
foo /sup/ssddssd/433443/fg54g4fg5-e653-4c13-81f3-bvbt4456gfdb4-43df
foo /eaa/asder-zxc2-bg34s-23xc-34sdf23ds2c-43dfgfd/fgfsdga/2432322
How can I only regex the fg54g4fg5-e653-4c13-81f3-bvbt4456gfdb4-43df pattern? The pattern isn’t always, as it shows, at the end of the strings.
I’ve tried [\w-]+ but it includes the entire string
>Solution :
To match two or more segments of word characters separated by hyphen, use
\w+(?:-\w+)+
\w+matches one or more word characters(?:-\w+)+followed by one or more\w+preceded by a hyphen
The non capturing group is used for repeating the contained part.