Factor out thr source code
and form a function call detectOperator.