RegEx applies one or more regex find & replace operations. (Applies two in this case.)
selstart and selend are both input and output. They tell you where the cursor was and what was selected, and you can modify them to change those things too.
These things can also be shared in XML form, which lets you import all the settings (not just the code) at once. Here it is, if you want to play with it:
<?xml version="1.0"?>
<regexsel key="219,3" name="Delete text in brackets from start and end, put cursor at end">
<eval>newstem = Trim(RegEx(valstem,
"^[\[\(][^\[\(\]\)]+[\]\)](.+)$", "\1",
"^(.+)[\[\(][^\[\(\]\)]+[\]\)]$", "\1"));
selstart = Len(newstem);
selend = selstart;
return newstem + valext;</eval>
</regexsel>