Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-23-2008, 07:31 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
Removing brackets from a text file

I have a text file like :
--ApplyTo:[Upgrade]
bla bla
--ApplyTo:[BusinessData]
IF NOT EXISTS(SELECT * FROM syscolumns WHERE id = OBJECT_ID('[og].[ClearVisionExport]') AND name = 'UserComment')
ALTER TABLE [og].[ClearVisionExport]
ADD [UserComment] [VARCHAR] (4000) NULL
--ApplyTo:[None]
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON

I need to remove all the brackets after ApplyTo so :
ApplyTo:[Upgrade] becomes ApplyTo:Upgrade
ApplyTo:[BusinessData] becomes ApplyTo:BusinessData
and so on.
I tried to implement a replace step(see the attachment) but I cannot make it working.
Any idea how to do this?
Attached Files
File Type: bld removebrackets.bld (1.8 KB, 1312 views)
Reply With Quote
  #2  
Old 04-23-2008, 07:40 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
The expression

ApplyTo:[[(\w+)]]

should be

ApplyTo:\[[(\w+)\]]

(square bracket characters have special meaning in regexes too and must be escaped to be treated as literals by the regex engine).

http://www.visualbuild.com/Manual/regex.htm
Reply With Quote
  #3  
Old 04-23-2008, 07:50 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
I see,thanks for info!
And what about the other part -from 'Text or regular expressions to replace matches with'?What should be there in order to have the item inside the brackets found previously?
Basically I need to have something like :
ApplyTo:ITEMINSIDEBRACKETS
but I do not know how to put it.
I looked in help but I still do not understand...
Reply With Quote
  #4  
Old 04-23-2008, 07:58 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
$1 or \1. Your sample worked in my tests after modifying as above and checking the Replace in File step (to include in the build).

4/23/2008 6:56:34 AM: --------------------Starting Build: 'removebrackets.bld'--------------------
4/23/2008 6:56:34 AM: Building project step 'Project steps'...
4/23/2008 6:56:34 AM: Building project step 'Create test file'...
Creating file C:\Temp\test.sql
4/23/2008 6:56:34 AM: Building project step 'Show test file'...
--ApplyTo:[Upgrade]
bla bla
--ApplyTo:[BusinessData]
IF NOT EXISTS(SELECT * FROM syscolumns WHERE id = OBJECT_ID('[og].[ClearVisionExport]') AND name = 'UserComment')
ALTER TABLE [og].[ClearVisionExport]
ADD [UserComment] [VARCHAR] (4000) NULL
--ApplyTo:[None]
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
4/23/2008 6:56:34 AM: Building project step 'Remove ApplyTo brackets'...
3 match(es) found, 3 replacement(s) made in file
4/23/2008 6:56:34 AM: Building project step 'Show test file after changes'...
--ApplyTo:Upgrade
bla bla
--ApplyTo:BusinessData
IF NOT EXISTS(SELECT * FROM syscolumns WHERE id = OBJECT_ID('[og].[ClearVisionExport]') AND name = 'UserComment')
ALTER TABLE [og].[ClearVisionExport]
ADD [UserComment] [VARCHAR] (4000) NULL
--ApplyTo:None
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
Reply With Quote
  #5  
Old 04-23-2008, 08:06 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
right ,works perfect with $1,thanks a lot!
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 02:58 PM.


Copyright © 1999-2023 Kinook Software, Inc.