bugfix, inBrackets actually works
This commit is contained in:
@@ -20,7 +20,7 @@ Finds $len characters of $str, starting at $idx (no prerequisites).
|
|||||||
|
|
||||||
### fun -string !inBrackets -string &str -char &left -char &right -int &instance
|
### fun -string !inBrackets -string &str -char &left -char &right -int &instance
|
||||||
|
|
||||||
Finds the content of the `$instance`th instance of brackets, with the left bracket being the $left char and the right bracket of $right char (requires !findCharInstance).
|
Finds the content of the `$instance`th instance of brackets, with the left bracket being the $left char and the right bracket of $right char (requires !findCharInstance and !mid).
|
||||||
|
|
||||||
### fun -bool !matchStart -string &str -string &instr
|
### fun -bool !matchStart -string &str -string &instr
|
||||||
|
|
||||||
@@ -41,3 +41,7 @@ You'll never guess what this does (it removes the last $num characters from a st
|
|||||||
### fun -bool !contains -string &str -string &instr
|
### fun -bool !contains -string &str -string &instr
|
||||||
|
|
||||||
Checks if $str contains $instr (requires !mid).
|
Checks if $str contains $instr (requires !mid).
|
||||||
|
|
||||||
|
### fun -list !split -string &str -string &splitstr
|
||||||
|
|
||||||
|
Returns a list of $str split apart depending on $splitstr, e.g. `split("a->b->c", "->")` returns `[a, b, c]` (requires !contains, !findStringInstance, !mid, !removeLeft).
|
@@ -47,6 +47,9 @@ fun -string !mid -string &str -int &idx -int &len
|
|||||||
set &ans ""
|
set &ans ""
|
||||||
lesser $idx 0 &store
|
lesser $idx 0 &store
|
||||||
if $store %end
|
if $store %end
|
||||||
|
greater $len 0 &store
|
||||||
|
if $store %loop
|
||||||
|
return ""
|
||||||
@loop
|
@loop
|
||||||
getstrsize $str &store
|
getstrsize $str &store
|
||||||
equal $store $idx &store
|
equal $store $idx &store
|
||||||
@@ -66,11 +69,26 @@ fun -string !mid -string &str -int &idx -int &len
|
|||||||
endfun
|
endfun
|
||||||
|
|
||||||
fun -string !inBrackets -string &str -char &left -char &right -int &instance
|
fun -string !inBrackets -string &str -char &left -char &right -int &instance
|
||||||
# Get start idx
|
# Get left idx
|
||||||
pusharg $str
|
pusharg $str
|
||||||
pusharg $left
|
pusharg $left
|
||||||
pusharg $instance
|
pusharg $instance
|
||||||
call !findCharInstance &store
|
call !findCharInstance &left
|
||||||
|
|
||||||
|
# Get right idx
|
||||||
|
pusharg $str
|
||||||
|
pusharg $right
|
||||||
|
pusharg $instance
|
||||||
|
call !findCharInstance &right
|
||||||
|
|
||||||
|
# Get inner string
|
||||||
|
add $left 1 &left
|
||||||
|
subtract $right $left &store
|
||||||
|
pusharg $str
|
||||||
|
pusharg $left
|
||||||
|
pusharg $store
|
||||||
|
call !mid &store
|
||||||
|
return $store
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
fun -bool !matchStart -string &str -string &instr
|
fun -bool !matchStart -string &str -string &instr
|
||||||
|
Reference in New Issue
Block a user