PDA

View Full Version : need help with regular expression match


LrngToFly
06-17-2009, 03:22 PM
Hello-

I've never used regular expressions and this is frustrating the heck out of me...

I have a text file where I'm trying to use a Replace in File call to replace "Version=1.0.5.0" in multiple locations in the file (not including the quotes). The text is in multiple locations in the file, and not necessarily at the beginning or the end of the line. The 1.0.5.0 can be any number- for example it can be 1.0.6.0 or 2.99.3.0. Up to three digits between each "."

Anyone know how I search for this? I've tried all sorts of things, but other than "Version=", I can't get anything to work...

I've tried
Version=([0-9]|[0-9][0-9]|[0-9][0-9][0-9]).([0-9]|[0-9][0-9]|[0-9][0-9][0-9]).([0-9]|[0-9][0-9]|[0-9][0-9][0-9]).([0-9]|[0-9][0-9]|[0-9][0-9][0-9])

also, from what I read, perhaps
Version=(\d+).(\d+).(\d+).(\d+)

Also, I really don't understand the what \ , ^ etc. do- or if I need one of those characters at the beginning. Thanks much for any help!

kinook
06-17-2009, 03:32 PM
See attached sample. For more help with regular expressions, see http://www.kinook.com/VisBuildPro/Manual/regex.htm

LrngToFly
06-17-2009, 03:53 PM
Great- thanks! It appears that your example doesn't use the regular expression syntax, correct?

After a couple of hours mucking around with regular expressions, I still don't understand much about them! Oh well...

Now for my follow-up question: Is there a way to examine a .dll or .exe and obtain it's version # information?

Thanks!

kinook
06-17-2009, 03:57 PM
[vbld_FSO.GetFileVersion("%WINSYSDIR%\user32.dll")]

http://www.kinook.com/VisBuildPro/Manual/scriptexpressions.htm
http://www.kinook.com/VisBuildPro/Manual/sysscriptfile.htm

LrngToFly
06-18-2009, 08:38 AM
Thanks for the info on the GetFileVersion.

The match on Version=* isn't quite working- it's chopping off the rest of the line of text- beyond Version=1.0.1.0

Here's a sample section:

<section
name="applicationConfigurationManagement"
type="Microsoft.ApplicationBlocks.ConfigurationManagemen t.ConfigurationManagerSectionHandler,Microsoft.App licationBlocks.ConfigurationManagement, Version=1.0.1.0,Culture=neutral,PublicKeyToken=7be 9c45ae0061408" />

So I probably do need to use regular expression matching, correct? I need a little hand holding on that- I've been unable to get even the simplist matching to work- say just searching for

Version=1

where 1 can be 1-9. I think I must have something simple wrong with the syntax. I've read the help over and over again, read web pages on regular expressions- I can't get anything to work... Any chance you could show me what to put in to search for

Version=x

where x is 1-9?

Thanks a bunch- you've been a big help already...!

kinook
06-18-2009, 08:59 AM
Attached.

LrngToFly
06-18-2009, 10:43 AM
Wow, that's a concise match expression. I think I just barely understand it- but it works great!

Thanks again for all your help! AL