Optimize regular expression in editor.js

Remove 'for' cycle and RegExp not useful.
Note: this commit doesn't resolve bug #336, #2372 and #2370