mIRC Home    About    Download    Register    News    Help

Print Thread
#250549 21/01/15 05:49 AM
Joined: Jun 2014
Posts: 248
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Ok so occationally A script I run comes across text that looks like this (these are trivia answers)

Oort (cloud)
the (cleveland) browns

I'd like to just remove that chunk in the parentheses
This syntax of course doesn't work
Code:
set %answer $remove(%answer,$chr(40) * $chr(41))

And I'm sure there is a perfectly good reason it doesn't. But heh, I just don't know how to do this. Also its kinda important that in the case of "the (cleveland) browns" that the second space that would exist after (cleveland) is removed goes away.

I don't know why I don't know how to do this, but any help would be nice. Ty.

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
'oort cloud' and 'the cleaveland browns' seem like better answers, are you sure you don't want to just remove the parentheses?

Joined: Jun 2014
Posts: 248
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Well, I intend to actually keep a copy of both answers and accept either. I just thought I'd keep that info out so that what I needed help with was more clear.

You know if I gave a clue by replacing all alpha characters with an underscore maybe the expected answer would be more clear and I could just remove the ( and ).

I suppose its worth asking if there is a short version of underscore since multiple underscores in a row often looks like a line, I'd like there to be a noticeable space between the characters, without having to insert extra spaces.


--The double underscore looks ok for what I need ‗. It leaves a small space when they are side by side.

Last edited by Belhifet; 21/01/15 06:26 AM.
Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Code:
var %x = 1
while (%x <= $numtok(%answer,32)) {
if ($left($gettok(%answer,%x,32),1) == $chr(40)) {
if ($right($gettok(%answer,%x,32),1) == $chr(41)) {
set %answer $remtok(%answer,$gettok(%answer,%x,32),1,32)
}
}
inc %x
}


I think i understand what you want it to do but correct me if i'm wrong smile it will remove any word that starts with ( and ends with )
P.S i didn't test it


Link Copied to Clipboard