Search code examples
regexsublimetext3

Creating an ungreedy regex in Sublime Text 3


How do I create an ungreedy regex in Sublime Text 3? Neither the \U nor the ? syntax seem to work.

This is my line of code:

if (isset($data) === false && is_null($data) === false && is_array($data) === false) {

And this is my regex:

(is(.+)\(\$(.+)\) === false)?

I should get nine separate matches (tested in Regexr):

isset($data) === false
set
data
is_null($data) === false
_null
data
is_array($data) === false
_array
data

Ready to replace with !is\2($\3), but it's capturing the entire statement, not three individuals.


Solution

  • try this: is([^(]+)\(\$([^)]+)\) === false

    replaced with !is\1($\2)

    see demo