PDA

View Full Version : Multiple Regular Expressions & Case Sensitive


mweinberger
07-04-2006, 09:34 PM
Hi,

1. Topic One (Multiple Indendent Expressions)

I'm a registered user of VBPro v6.1 and have a question on regular expressions. I want to create a single "Replace in File" action that operates on a single file. I would like 5 independent search and replaces performed. The way that I'm envissioning things is that each line in the "Text or regular expression to find:" box would match a line in the "Text or regular expression to replace matches with:".

"Text or regular expression to find:"
=========================
FILEVERSION\s.*
PRODUCTVERSION\s.*
"FileVersion", ".*
"ProductVersion", ".*
"LegalCopyright", ".*
=========================

"Text or regular expression to replace matches with:"
======================================
FILEVERSION %VERSION_IMMOD_FILE%
PRODUCTVERSION %VERSION_IMMOD_PRODUCT%
"FileVersion", "%VERSION_IMMOD_FILE%"
"ProductVersion", "%VERSION_IMMOD_PRODUCT%"
"LegalCopyright", "%LEGALCOPY_IMMOD%"
======================================

As you can see there are five independent search and replaces. I tried what you see above and it didn't work. I seem to recall that I have to add something. I just don't remember what.

2. Topic Two (Case Sensitive Expressions)

How can I make the search for a particular expression case senstive. The "fileversion" in the expression (FILEVERSION\s.*) is different than the "fileversion" in the expression ("FileVersion", ".*).

Thanks in advance,

kinook
07-05-2006, 08:01 AM
Another way to do that would be to use a Make VC6 or Make VS.NET action, setting the values on the Versions and Properties tabs (you can specify a .rc file or .dsp/.dsw/.vcproj/.sln for the filename to process).

To perform multiple regular expression replacements w/ the Replace in File action, see the Fixup RC File step in the Files.bld sample and http://www.visualbuild.com/Manual/replacetexttab.htm

To perform case sensitive matching, check the 'Perform case-sensitive matching' on the Replace tab: http://www.visualbuild.com/Manual/replacetab.htm

mweinberger
07-05-2006, 09:00 AM
She works! Thanks! The only problem that I had is that there cannot be any embedded carriage returns between the () blocks in the find and the (?#) blocks in the replace with areas.

kinook
07-05-2006, 09:35 AM
See the 'Allow comments and ignore whitespace (Perl extended mode)' option.
http://www.visualbuild.com/Manual/replacetab.htm