Answer the question
In order to leave comments, you need to log in
How to build a regular expression for syntax processing?
Because I blog (although this is more of a note from life) I try to arrange everything beautifully.
Before that, I used a simple tag to insert commands from RouterOS
. I sat down and thought about writing a simple plugin for Wordpress for syntax highlighting, like in the RouterOS terminal: It's a
start, but I ran into a problem. Namely, with regular expressions .. Yes, yes, those very ones, with the help of which you need to catch characters, certain commands and a bunch of everything else.
I ask for all possible help in writing a plugin, or rather in writing a regular expression.
Code on github:
Code on GitHub
At the moment I'm using the preg_replace
Split code feature to search for different sets, here's the search for Incoming Menus:
$commandTerm and $inputTerm are a set of commands that can be entered separated by spaces in a textarea in a plugin.
Those. all the words that we need to find we enter into various inputs (textarea)
/([\:])('.$commandTerm.')|[\/]('.$inputTerm.')[\s]|\b('.$inputTerm.')\b/ui
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question