To specify exactly "di" and match only that string, you must use the regex "^di$", where the caret ^ indicates start of line and $ indicates end of line.
If you want to specify a single di that is with and without a target, there are multiple ways to do it depending on your needs.
For example if you want di to target someone when you have a target variable set, but not target anyone when not, then you need to put in an IF condition in the script box. Something like (in pseudocode):
if ( not exist target ) then
send ( "c 'dispel magic'" )
else
send ( "c 'dispel magic' " .. target )
endif