2

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.

2
  • You'll probably want to ask this on StackOverflow, and it will likely be moved there shortly. Feb 3, 2010 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, 2010 at 12:23

1 Answer 1

1

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.

1
  • Thanks! If I skip the perl stuff it seems to work just fine.
    – berocoder
    Feb 4, 2010 at 8:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .