I am not very familiar with regular expressions and ran into a problem which is beyond me. I would like help with coming up with an expression which tokenizes a string and then gets me everything BUT arbitrary tokens counting from the end.
For example, I would like to get everything BUT P037-077
from the following string
http://www.wayfair.com/George-Kovacs-by-Minka-Bling-Bling-1-Light-Wall-Sconce-P037-077-GKV1032.html
One approach to do this is to start counting tokens backwards with the delimiter being "-" (there is no guarantee of how many tokens there are to the left of the required part of the string) and get the 2nd and 3rd token and then get everything BUT that.
I got 90% of the expression which is -([^-]*-[^-]*)-[^-]*$
This returns P037-077
but I need to get the complement of that.
I don't know if I've explained very well. I will be happy to explain again if anything is unclear.
I know this can be done easily by tokenizing in any language but unfortunately I do not have the freedom to do that as the tool I am using takes only regex as an input. It uses the Java syntax.