mIRC Home    About    Download    Register    News    Help

Print Thread
exctract text from line #268322 05/01/21 06:31 PM
Joined: Jan 2021
Posts: 2
F
fractal Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
F
Joined: Jan 2021
Posts: 2
hi there
havent been able to find out how to extract text from a long line
the line waries in length and characters but have 2 static points , the "/" that divides them.
the line would look something like this: "some.long.random.word/[31x:]/another.random.word"
i would like to get: "another.random.word" = var1 and "another.random.word" = var2
dont want to remove any special characters in the "words"
no problem if its done in 2 stadges
thnx

Re: exctract text from line [Re: fractal] #268328 06/01/21 12:47 AM
Joined: Jan 2004
Posts: 1,481
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,481

//tokenize $asc(/) some.long.random.word/[31x:]/another.random.word | echo -a $1 vs $2 vs $3 vs $1-

You can use a literal 47 instead of $asc(/)

If the string is already in a %variable you can use $gettok(%variable,1,47) to fetch the 1st token

Re: exctract text from line [Re: maroon] #268330 06/01/21 11:32 AM
Joined: Jan 2021
Posts: 2
F
fractal Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
F
Joined: Jan 2021
Posts: 2
worked like a charm with $gettok(%var1,1,47) and $gettok(var2,3,47)
thnx