To match a string to a pattern, for example:
-TEXT-someMore-String
To get -TEXT- , I found out that this works:
/-(.+?)-/ // -TEXT-
How do i know ? makes the previous token as optional, as in:
colou?r matches both colour and color
I first put in regex to get the -TEXT- part as follows:
/-(.+)-/
But he gave -TEXT-someMore- .
How to add ? stops the regular expression to get the -TEXT- part correctly? Since he used to make the previous token optional, without stopping at a certain point, as in the example above?
source share