Originally Posted By: gans
deegee:
thanks for that example its working fine i was trying to use $hfind with the r switch
but nothing was working for me u gave me a nice example but can u explane this bit for me
$+(/,%pack,/Si) whats the / and /Si for?

/../Si
"/" mark the beginning and end of the search pattern
"S" is a switch to strip color/bold/etc before matching
"i" is case insensitive



Originally Posted By: gans
hmm theres sumthing rong it dont work with [ or ] how can i make it work with them?

Code:
alias example {
  var %pack = text to find
  var %re = $+(/\Q,$replacecs(%pack,\E,\E\\E\Q),\E/Si)
  hadd -m example item some 00,02text 11t04O 11f00iND
  if $hfind(example,$+(/,%pack,/Si),1,r).data {
    echo -ag $v1 = $hget(example,$v1) $+([Searched for: ",%pack,"])
  }
  hfree example
}

\Q and \E : Characters in between are treated literally, no special regex meanings apply.
However, the string may contain "\E", so "\E" needs to be replaced with "\E\\E\Q" to restart the escape sequence.