mIRC Home    About    Download    Register    News    Help

Print Thread
Hint answer ignoring capital letters and spaces... #147232 16/04/06 12:26 PM
Joined: Apr 2006
Posts: 2
H
Hoek Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
H
Joined: Apr 2006
Posts: 2
How to replace alternative letters in a word or sentence, ignoring capital letters and spaces?

examples:
A Few Good Men --> A F*w G*o* M*n
Scent of a Woman -> S*e*t O* A W*m*n
Scream --> S*r*a*

Thanks

Re: Hint answer ignoring capital letters and space #147233 16/04/06 04:43 PM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
$replace(text/phrase, text/letter to replace, text/letter to replace with)

Examples:

$replace(It is a good day, good, bad) ---> It is a bad day
$replace(AaAa, a , b) ---> bbbb

There is also $replacecs() which takes the same parameters, and can be used to specifically replace capitals with capitals, lower with lower, etc.

Examples:

$replacecs(AaAa, a, x, A, Y) ---> YxYx
$replacecs(It is a Good day and a good month, good, bad) ---> It is a Good day and a bad month

Also look at /help $replace

Re: Hint answer ignoring capital letters and spaces... #147234 16/04/06 07:24 PM
Joined: Apr 2006
Posts: 2
H
Hoek Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
H
Joined: Apr 2006
Posts: 2
I was thinking more about that old "Hint challenge" stuff...

Re: Hint answer ignoring capital letters and space #147235 16/04/06 11:06 PM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Try this:

Useage: $chint(text)

Code:
alias chint {
  if (!$isid) return
  var %text = $replace($strip($1-),$chr(32),$chr(183))
  var %i = 1, %l = $numtok(%text,183)
  var %tok, %toklen, %j, %result
  while (%i <= %l) {
    var %tmp
    %tok = $gettok(%text,%i,183)
    %toklen = $len(%tok)
    %j = 1
    while (%j <= %toklen) {
      if ($calc(%j % 2)) %tmp = $+(%tmp,$mid(%tok,%j,1))
      else %tmp = $+(%tmp,_)
      inc %j
    }
    %result = $+(%result,$chr(183),%tmp)
    inc %i
  }
  return $replace(%result,$chr(183),$chr(32))
}

Re: Hint answer ignoring capital letters and spaces... #147236 16/04/06 11:56 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
Scent of a Woman -> S*e*t O* A W*m*n


I beleive your example is incorrect by the way. to what you requested at least.

Scent of a Woman -> S*e*t *f * W*m*n
Scent Of A Woman -> S*e*t O* A Wo*a*

Anyway, assuming its what ya requested, try this usage is $makestars(<your text here>)
* Your text should be any one line of text, not exceeding 400 characters.

Code:
alias makestars {
  var %text = $replacecs($1-,*,$cr,$chr(32),$lf,a,*a,b,*b,c,*c,d,*d,e,*e,f,*f,g,*g,h,*h,i,*i,j,*j,k,*k,l,*l,m,*m,n,*n,o,*o,p,*p,q,*q,r,*r,s,*s,t,*t,u,*u,v,*v,w,*w,x,*x,y,*y,z,*z)
  var %i = 1
  while ($pos(%text,*,%i)) {
    var %text = $+($left(%text,$calc($v1)),$mid(%text,$calc($v1 + 2)))
    inc %i
    if ($pos(%text,*,%i)) {
      var %text = $+($left(%text,$calc($v1 - 1)),$mid(%text,$calc($v1 + 1)))
    }
  }
  return $replace(%text,$cr,*,$lf,$chr(32))
}

Re: Hint answer ignoring capital letters and space #147237 17/04/06 12:07 AM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
I interpreted his request as follows, which is how I made the code:

The replacement should start at the second letter of each word and then every other letter after that, still within the current word.

Re: Hint answer ignoring capital letters and space #147238 17/04/06 04:57 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Oh i never said your code was wrong (actually i never even checked it, i assumed it worked due to the level of complexity it looked like it had [ie: i assumed you didnt write it in the editor here])
I just mentioned his "How to replace alternative letters in a word or sentence, ignoring capital letters and spaces?" didnt gel with his examples.

To me he said take every other lowercase letter and make it a *.
He never said to capitalize anything so i assumed he botched his example (i make no refrence to your code, i dont know f it caps or not)