Suppose I have this information :` “cheese-olives-peppers-olives” , “cheese-olives” “cheese-tomatoes-olives” , “cheese”:
I want to learn how to write regex expressions to find
x1: everything from the start position to the first (e.g. cheese, cheese, cheese, cheese)
x2: everything after the first – to the second – (e.g. olives, olives, tomatoes, NULL)
x3: everything from the second – to the end position (e.g. peppers, NULL, olives, NULL)
I tried this
x1 = '^[^-]*'
x2 = '(?<=-)[^-]*'
x3 = '(?<=-[^-]*-).*'
X1 and X2 work, but X3 does not.
How can I try to fix this?