|
Joined: Oct 2017
Posts: 47
Ameglian cow
|
OP
Ameglian cow
Joined: Oct 2017
Posts: 47 |
Hello  I wanna suggest a new identifier to be able to move an old string position item into an new position on the text. Usage: $movetok(text,string,new-position,character)Example: $movetok(one three two,two,2,32) = one two three Note: Also $movetokcs() for case-sensitive usage. - Thanks!
|
|
|
|
Joined: Feb 2003
Posts: 2,812
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 2,812 |
The trouble I see here, from a purely functional standpoint, is that your suggestion only represents one of the several ways that $*tok functions work. It compliments the "matching string" methods of $findtok(), $istok(), $matchtok(), $remtok() and $reptok(), but it doesn't do anything for the "matching index" methods of $deltok(), $gettok(), $instok(), $puttok()... nor does it support the wildcard matching of $wildtok(). Of course, it goes without saying that your $movtok() functionality can be solved by combining only two of the aforementioned identifiers. ; $movetok(one three two, two, 1, 2, 32)
; $movetok(text, token, N, M, C)
ALIAS movtok { return $instok($remtok($1,$2,$3,$5),$2,$4,$5) }
ALIAS movtokcs { return $instokcs($remtokcs($1,$2,$3,$5),$2,$4,$5) }
The N parameter is used to specify which occurrence of the matching token to work on.
see /help $remtok().
Well. At least I won lunch. Good philosophy, see good in bad, I like!
|
|
|
|
Joined: Oct 2017
Posts: 47
Ameglian cow
|
OP
Ameglian cow
Joined: Oct 2017
Posts: 47 |
So a new IRC comment (thx Talon) about that post idea came out, so the question about this is.. what if 2 same or more strings exists on text parameter.. And the answer is it can to work as $remtok() identifier, i will provide new examples.
Usage: $movetok(text,string,N,[N],C)
text == The original text string == The match token on text value N == The N position on text value [N] == Optional, If N = 0, applies to all matching items (same as $remtok() identifier) C = The C parameter is the ascii value of the character separating the tokens.
Examples: $movetok(one three two,two,2,32) == one two three || $movetok(one three two four two,two,2,0,32) == one two two three four
|
|
|
|
Joined: Jan 2004
Posts: 2,127
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 2,127 |
Fleshing this out a little more, I'm assuming that if the '2' exceeded the number of tokens in TEXT that it should move to be the final token. And using -1 would move it to be the final position, -2 moves to be the next-to-last token, etc. If STRING is not within TEXT, then it returns the unaltered string.
|
|
|
|
|