mIRC Home    About    Download    Register    News    Help

Print Thread
Getting strings between 2 things... #4609 02/01/03 10:29 PM
Joined: Dec 2002
Posts: 54
L
laz Offline OP
Babel fish
OP Offline
Babel fish
L
Joined: Dec 2002
Posts: 54
Ok I want to get the info between 2 quotation marks. I think I'll explain this better with an example:

%test Hi "Hello" "..." more stuff "BLAH"

Say if I only wanted to get stuff that is in the quotation marks (which would be "Hello ... BLAH").

Any ideas?

Re: Getting strings between 2 things... #4610 02/01/03 10:57 PM
Joined: Dec 2002
Posts: 40
L
Lucifer Offline
Ameglian cow
Offline
Ameglian cow
L
Joined: Dec 2002
Posts: 40
/help $gettok
Code:
test {
var %test = $gettok(Hi "Hello" "..." more stuff "BLAH",1,34) $gettok(Hi "Hello" "..." more stuff "BLAH",4,34) $gettok(Hi "Hello" "..." more stuff "BLAH",6,34)
}

that will do what you specified though it could probably be done cleaner you'll just have to look for yourself


Re: Getting strings between 2 things... #4611 03/01/03 12:40 AM
Joined: Dec 2002
Posts: 1,321
H
Hammer Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Code:

alias quoted.stuff.only {
  var %string, %i = $iif("* iswm $1,1,2)
  while ($gettok($1-,%i,34)) { %string = %string $ifmatch | inc %i 2 }
  echo -ati2 " $+ %string $+ "
}

/quoted.stuff.only Hi "Hello" "..." more stuff "BLAH"
"Hello ... BLAH"

Last edited by Hammer; 03/01/03 09:05 AM.

DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Re: Getting strings between 2 things... #4612 03/01/03 08:46 AM
Joined: Dec 2002
Posts: 699
N
Nimue Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Code:
alias quoted {
  var %r,%i = 1
  .!echo -q $regex($1-,/\x22(\S*?)\x22/g)
  while ($regml(%i)) { var %r = %r $ifmatch | inc %i }
  if (%r) return $+(",%r,")
}
//echo -a $quoted(Hi "Hello" "..." more stuff "BLAH")
"Hello ... BLAH"