to be expert = مَهَرَ

مَهَرَ (imperfect يَمْهُرُ , verbal noun مَهَارَةً ) means to be expert, or skilled in something. It can be used transitively (so would resemble the English verb to master something), or can be followed by فِيْ or بِ , e.g. مَهَرَ النَّحْوَ / فِي النَّحْوِ / بِالنَّحْوِ he mastered, became an expert in grammar. The use of فِيْ with verbs is often to indicate the area or subject matter to which the verb pertains (e.g. صَنَّفَ كِتَابًا فِي التَّصّوُّفِ he wrote a book about Sufism), so in our example, the meaning would be he became an expert in (the field of) grammar. The use of بِ with verbs can be to indicate the object to which an act applies (e.g. بَخِلَ بمَالِهِ he was stingy with (regards to) his money), so in our example, the meaning would be he became an expert in (regard to) grammar.