Need Help With Regular Expression

Hi, I’m trying to turn input from textarea into an array

here is what the textarea input look like

[input 1] [input 2] [input 3]

I’m trying to split everything inside the square bracket “” into an array.

here are my codes

$option = array();
$regex = "#[\\[^]]*#s";
$input = "[input 1] [input 2] [input 3]";

$option = preg_split($regex, $input, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );

the output is

    [0] => input 1]
    [1] => input 2]
    [2] => input 3]

the closing bracket still there, So what am I missing the regex pattern? Thanks

I think you can avoid RegExp all together.
Use explode instead.
You should trim leading and trailing square brackets first with:

$option = explode("] [", trim($input, "[]"));

This is a good way to create the array but since the input is inputted using texarea I cannot take control of the input it may be have enter or space between each bracket are there any solutions?

Hi, I have solve this by using this regex