Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The background is that I have a complicated memory issue in Delphi. But a theory is that an enum of 5 values can be the root of the bug. So my question to you is:

How do I write a regexpression to search sourcefiles for an enum with 5 values ? An enum in Delphi looks like this

myEnum = (value1,value2,value3,value4,value5);

There can of course be any combination of spaces, tabs and newlines between the values.

share|improve this question
You'll probably want to ask this on StackOverflow, and it will likely be moved there shortly. – Joe Internet Feb 3 '10 at 11:19
I was not sure what forum was best. But my thought was that regexpressions is not for programmers only. It is handy to search all kinds of text. In this case it happens to be a source file for Delphi. But if the question was moved it is ok for me :) – berocoder Feb 3 '10 at 12:23
up vote 1 down vote accepted

this should give you all the lines you are searching for in your files:

perl -n -e 'if ($_ =~ m/\W*\w+\W*=\W*\(\W*\w+\W*,\W*\w+\W*,\W*\w+\W*,\W*\w+\W*,\W*\w+\W*\)\W*;/) { print $_; }'

just parse all you delphi source files through this perl one liner.
some more explanations:

  • \W => means non-word character
  • \w => means alphanumerical character including underscore
  • + => at least one occurrence
  • * => zero or more occurrence
  • $_ => current line of which will be filled by -n

hope this helps.

share|improve this answer
Thanks! If I skip the perl stuff it seems to work just fine. – berocoder Feb 4 '10 at 8:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.