get the begging of a string until a given char - c : I know that is a simple question but I couldn't find the answer,

I have this string: 

    M1[r2][r3]

I want to get only the M1, I'm looking for something like ```strchr()```
a function that get the string and a char to stop at.

Thanks.