Regular Expressions for Subversion keywords

Here are different Regular Expressions to identify the common (to me at least), the Subversion keyword: $Id$ on different type of files (depending on how the comments go).

This one is for languages derived from C (like C++, C#, PHP, Java, JavaScript):

// \$Id\: [A-Za-z0-9\ \:\.\-\_]* \$

It will match something like:

// $Id: filename 3 2010-06-23 15:48:28Z username $

This one also for languages like C, but also, CSS:

/\* \$Id\: [A-Za-z0-9\ \:\.\-\_]* \$ \*/

It will match something like this:

/* $Id: filename 3 2010-06-23 15:48:28Z username $ */

This one for Velocity files (as I’m using Castle MonoRail with NVelocity):

\#\# \$Id\: [A-Za-z0-9\ \:\.\-\_]* \$

That will match:

## $Id: filename 3 2010-06-23 15:48:28Z username $

So now, with these expressions, you can do some things like remove them from your code (if you are like me and are moving to Git).

Leave a Reply

  

  

  


× 9 = fifty four

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>