mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2003
Posts: 70
M
Babel fish
OP Offline
Babel fish
M
Joined: Sep 2003
Posts: 70
For evaluation of the replace text after the matches are replaced.

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
The \E \U \L modifiers themselves wouldn't be the issue, as PCRE doesn't recognize these (yet).

Whether or not Khaled can write his own implimentation is another story though. Yes, it would be exceedingly handy to have string manipulation control over \1 in the replacement text of $regsub.

I would suggest adding a new //flag that indicates replacement text is an $identifier and have \1 \2 \3 passed as $1 $2 $3. This way your identifier can perform complex string manipulation on each back-reference and /return exactly what you want it to replace with. Also, $rawmsg should be populated with the contents of \0 (as $0 cannot be).

[color:000066]/.!echo -q $regsub(%s,/[regex]/[color:red]A[/color],titlecase,%s)

ALIAS titlecase {
  return $upper($left($1,1)) $+ $mid($1-,2)
}[/color]

This would function much like the new /debug -i switch.

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
That would be amazingly handy indeed.. I hate having to loop using $regml frown


* cold edits his posts 24/7
Joined: Sep 2003
Posts: 38
O
Ameglian cow
Offline
Ameglian cow
O
Joined: Sep 2003
Posts: 38
This is difficult to do in an alias, but it can be done. $regsub doesn't like replacements with identifiers in them. Here's an alias I made to solve the problem (remember to use $!identifier instead of $identifier) :
Code:
; Slightly different from $regsub: you don't put a variable as the last argument.
; Example: echo 4 -a IAL entries: $regsube(test *!*@* test, /^.*(\S+\!\S+@\S+).*$/, $!ial(\1, 0))
alias regsube {
  var %original = $1, %regex = $2, %replacement = $replace($3, $, $chr(1)), %result
  .echo -q $regsub($1, $2, %replacement, %result)
  set %result $replace(%result, $chr(1), $)
  set %result $eval(%result, 2)
  return %result
}

Joined: Sep 2003
Posts: 70
M
Babel fish
OP Offline
Babel fish
M
Joined: Sep 2003
Posts: 70
The problem with that is that it will evaluate any expressions already in the original. It will also not work properly if the thing being replaces is not one word.


Link Copied to Clipboard