Hello, I want to know how can I split a string which contains " " (space), but outside quotes.
I tried a variety of functions, neither of them worked. I even tried making a stock, but don't know where the problem is.
For instance, this is a full string: "value num1" "value num2". Instead of returning "value" "num1 ..." it would return the correct way, "value num1","v...".
(Used this ->)
PHP Code:
stock string_arg_split(const string[],right[],left[],const delim[])
{
new return_right[128]
new return_left[128]
new bool:in_quote
new bool:is_right
for(new i=0;i<strlen(string);i++)
{
if(equal(string[i],"^"")) // Code below is red, wth?
{
if(in_quote)
{
in_quote=false
}else{
in_quote=true
}
}
if(!in_quote && equal(string[i],delim))
{
if(is_right)
{
is_right=false
}else{
break
}
}else{
if(is_right)
{
add(return_right,charsmax(return_right),string[i])
}else{
add(return_left,charsmax(return_left),string[i])
}
}
}
set_string(2,return_right,strlen(right))
set_string(3,return_left,strlen(left))
}
Thank you in advance !