I need a regex to match following strings:
input ---> output
------------------------------
1*a12*asd*315 ---> a12
113-a12-asd*315 ---> a12
+1-a12-asd-315 ---> a12
as3-a12-asd*315 ---> a12
as3-a12-a ---> a12
a-a12-a ---> a12
a-a12-aas ---> a12
-a12-aas-asd ---> a12
*a12*aas*asd ---> a12
a*a12*aas*sd ---> a12
Hope examples are enough. What I tried is:
(^(?=.{1,3}$)-([a-zA-Z])-(?=.*)$)
but not working? What will be the correct regex for this?
for examples I have used a12. It can be anything. I don’t know what the string will be, need to extract that.
You could use an expression like:
The desired value will be in the second capturing group after successful match.