13,254
edits
Line 561: | Line 561: | ||
== Troubleshooting of regular expression == | == Troubleshooting of regular expression == | ||
Tips | Tips | ||
* Small data test: (1) Prepare the small file data to verify the syntax (2) Using the [[Regular_expression#Regular_expression_online_tools | online tools]] | |||
* Highlight or output the matched text e.g. {{kbd | key=<nowiki>--color</nowiki>}}<ref>[https://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/grep_command_examples/ Grep -color command Examples - nixCraft]</ref> for grep command or output the matches by PHP [http://php.net/manual/en/function.preg-match.php preg_match()] function. | |||
* Simplify the syntax | * Simplify the syntax | ||
* Because the compatibility issue, you may try to use the alternative syntax e.g. {{kbd | key=<nowiki>\d</nowiki>}} to {{kbd | key=<nowiki>[0-9]+</nowiki>}}. | * Because the compatibility issue, you may try to use the alternative syntax e.g. {{kbd | key=<nowiki>\d</nowiki>}} to {{kbd | key=<nowiki>[0-9]+</nowiki>}}. | ||