Question: I want parse something like a section entry in an \*.ini file:

```
line='      [          fdfd fdf         f   ]  '

```

What could be the sed pattern (???) for this line to split the

```
'fdfd fdf         f'

```

out?

So:

```
echo "${line}" | sed -E 's/???/\1/g'

```

How can I describe all chars except `[[:space:]]`, `[` and `]` ? This doesn't work for me: `[^[[:space:]]\[]*` .

Answer: 
When you use the `[[:space:]]` syntax, the outer brackets are normal "match one character from this list" brackets, the same as in `[aeiou]` but the inner brackets are part of `[:space:]` which is an indivisible unit.

So if you wanted to match a single character which either belongs to the `space` class or is an `x` you'd use `[[:space:]x]` or `[x[:space:]]`

When one of the characters you want to match is a `]`, it will terminate the bracketed character list unless you give it some special treatment. You've guessed that you need a backslash somewhere; a good guess but wrong. The way you include a `]` in the list is to put it first. `[ab]c]` is a bracketed list containing the 2 characters `ab`, followed by 2 literal-match characters `c]`, so it matches `"ac]"` or `"bc]"` but `[]abc]` is a bracketed list of the 4 characters `]abc` so it matches `"a"`, `"b"`, `"c"`, or `"]"`.

In a negated list the `]` comes immediately after the `^`.

So putting that all together, the way to match a single char from the set of all chars except the `[:space:]` class and the brackets is:

```
[^][:space:][]

```

The first bracket and the last bracket are a matching pair, even if you think it doesn't look like they should be.
When you say split, do you mean *split into an array*, or do you mean *filter* out all spaces and brackets?

Assuming the value of line number 1 in file.ini is:

```
  [          fdfd fdf         f   ]  

```

If you mean array,

```
$linenumber=1;
array=($(sed -n ${linenumber}p file.ini | sed 's/[][]*//g'));

```

will split line number 1 of file.ini into an array and return the values:

```
${array[0]} = fdfd
${array[1]} = fdf
${array[2]} = f

```

If you mean filter spaces and brackets,

```
$linenumber=1;
sed -n ${linenumber}p file.ini | sed 's/[ []]*//g';

```

will return:

```
fdfdfdff

```

and if *neither of those* is what you meant, **please specify the exact output** you are looking to extract from the initial value so that we can address it correctly.