May I ask the seperate options you are supplying for the user?

is it something like:
Match as whole work only=word1 word2
Match as word part=word3 word4

Code:
alias -l safeRegex return $regsubex($1-, /([^a-z\d_-])/g, \E\ $+ \t $+ \Q)



if (*word* isin $strip($1-)) {
  ;; matches for "word" anywhere in text
}
elseif ($regex($strip($1-), /\b\Q $+ $safeRegex(word) $+ \E\b/i)) {
  ;; matches "word" as a whole word only (can be preceded or followed by punctuation)
}
elseif ($regex($strip($1-), /\b\Q $+ $safeRegex(word) $+ \E/i)) {
  ;; matches if "word" is the start of a word(can have punctuation before, anything after)
}
elseif ($regex($strip($1-), /\Q $+ $safeRegex(word) $+ \E\b/i)) {
  ;; matches if "word" is the end of a word (anything before, punctuation after)
}



Last edited by FroggieDaFrog; 24/02/15 10:53 PM.

I am SReject
My Stuff