Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm looking for a possibility to use regular expression in listings. I'd like to highlight each N thats followed by 4 decimal numbers for example N1234. How can I achieve that?

Here is an example:


{morekeywords={N\d\d\d\d},  % <-- regular expression ???

\lstnewenvironment{mylang}{\lstset{language=NCSyntax, keywordstyle=\color{red}\bfseries\underbar }}{}

N1234   ; colored as keyword
A1234   ; text
N12     ; text
N12345  ; text
N4242   ; colored as keyword                
share|improve this question

closed as off-topic by Joseph Wright Aug 12 '13 at 20:18

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

Welcome to TeX.SE. I assume by "decimal numbers" you mean "digits 0 thru 9". – Peter Grill Apr 9 '13 at 7:33
yes I mean digits 0-9 – Lukas Apr 9 '13 at 7:46
This question appears to be off-topic because it is a feature request for a package. – Joseph Wright Aug 12 '13 at 20:18
Supporting regexs would be a very big feature request for listings (or indeed most TeX packages), and so is really outside of our scope. – Joseph Wright Aug 12 '13 at 20:18
@JosephWright If this question should be closed, it should be as "too broad" rather than as "off topic". – Jubobs Jan 16 '14 at 14:07