What is the difference between .*? and .* regular expressions?

I’m trying to split up a string into two parts using regex. The string is formatted as follows:

text to extract<number>

I’ve been using (.*?)< and <(.*?)> which work fine but after reading into regex a little, I’ve just started to wonder why I need the ? in the expressions. I’ve only done it like that after finding them through this site so I’m not exactly sure what the difference is.

3 Answers

Leave a Comment