I am trying to write a regular expression that can extract different types of string+number+symbol combinations out of a string. The types of strings I am trying to extract are:
avs-tldr-02
cc+asede
x86_64
The types of edge cases I am testing are these string appearing at the beginning, middle and end of sentences:
avs-tldr-02 this is a test
cc+asede this is a test
x86_64 this is a test
this is a test avs-tldr-02 this is a test
this is a test cc+asede this is a test
this is a test x86_64 this is a test
this is a test avs-tldr-02
this is a test cc+asede
this is a test x86_64
Based on this excellent answer, I have dabbled around with "lookaround" assertions in RegEx and have come up with the following:
(?=.*[:alnum:])(?=.*[:punct:])([a-zA-Z0-9_-]+)
However, this keeps matching the first word of the string - I understand why this is happening, but am at a loss of how to tweak this to work for my use case.
How do I modify this to get what I am looking for/are there any other ways to tackle this issue?