Page 1 of 1

replaceing multiple lines

Posted: Mon Sep 19, 2005 4:20 pm
by larryse
I need 2 lines of text changed if another line exists.

If this line is found
RTText = {

I need to replace these 2 lines
FontSize = 16.0000 ;
FontHeightPct = 55.00000 ;

the trick is the lines are not all in a row but the are always the same number of rows apart. also both of the replacing lines may not need changing.

Can this be done??

Thanks
Larry

Posted: Tue Sep 20, 2005 2:11 pm
by Abacre
Yes, it's possible.
Please give us the samples:
source text and resulting text (after up replacements).

Posted: Tue Sep 20, 2005 3:46 pm
by larryse
The bold lines are the ones in quesrtion

RTText = {
LabelText = "Anterior:" ;
FontName = "system default" ;
FontSize = 16.00000 ;
LabelActiveColor = 7 ;
BackgroundColor = 252 ;
ShowBackground = True ;
Justification = 0 ;
DataType = 0 ;
TotalDigits = 50 ;
DecimalPoints = 2 ;
InitiallyActive = True ;
RTEnable = False ;
RTPoint = "" ;
RTServer = "CMX" ;
DataQualityEnable = 3 ;
RTUnits = "" ;
ControlPanel = "" ;
FontHeightPct = 75.00000 ;
FloatNotation = 0 ;
WinFontSpecsSupported = 1 ;
TextAttachType = 0 ;
ShowUnits = False ;

Changes to
RTText = {
LabelText = "Anterior:" ;
FontName = "system default" ;
FontSize = -1.000000 ;
LabelActiveColor = 7 ;
BackgroundColor = 252 ;
ShowBackground = True ;
Justification = 0 ;
DataType = 0 ;
TotalDigits = 50 ;
DecimalPoints = 2 ;
InitiallyActive = True ;
RTEnable = False ;
RTPoint = "" ;
RTServer = "CMX" ;
DataQualityEnable = 3 ;
RTUnits = "" ;
ControlPanel = "" ;
FontHeightPct = 35.00000 ;
FloatNotation = 0 ;
WinFontSpecsSupported = 1 ;
TextAttachType = 0 ;
ShowUnits = False ;

thanks

Posted: Wed Sep 21, 2005 7:02 am
by Abacre
Thank you for sample texts. It's clear now.


In main menu - Action - Options - Batch replace
check ON: "Modifier S".

Go to Batch replace tab. Check ON: "Use regular expressions".
Search for:
RTText = {(.*)FontSize = 16\.00000 ;(.*)FontHeightPct = 75\.00000 ;

Replace with:
RTText = {$1FontSize = -1.000000 ;$2FontHeightPct = 35.00000 ;

So: .* means any char.
we pick up text between RTText = { and FontSize = using ()
then in replace part we recover it using $1
we use 16\.00000 because . is a reserved char. So we should escape it
using \.

I verified it worked fine.

Posted: Wed Sep 21, 2005 5:16 pm
by larryse
thanks Roman

Posted: Thu Sep 22, 2005 11:11 pm
by larryse
I get an error saying

Error during compilation of regular expression (row number 1):
"Search For" part*+Operand Could Be Empty(pos9)

What have I done wrong?

thanks

Posted: Fri Sep 23, 2005 11:10 am
by Abacre
It's strange because it did work on my computer.
Try also to escape { char using \.
So use the Search for:
RTText = \{(.*)FontSize = 16\.00000 ;(.*)FontHeightPct = 75\.00000 ;

Posted: Fri Sep 23, 2005 5:04 pm
by larryse
i screwed somethings, had boxes checked that weren't need, your original reply work like a charm.

One more question,
How would it do the same as above but say exclude items that meet certain requirements.

eg.
RTText = {
LabelText = "Anterior:" ;
FontName = "system default" ;
FontSize = 16.00000 ;
LabelActiveColor = 7 ;
BackgroundColor = 252 ;
ShowBackground = True ;
Justification = 0 ;
DataType = 0 ;
TotalDigits = 50 ;
DecimalPoints = 2 ;
InitiallyActive = True ;
RTEnable = False ;
RTPoint = "" ;
RTServer = "CMX" ;
DataQualityEnable = 3 ;
RTUnits = "" ;
ControlPanel = "" ;
FontHeightPct = 75.00000 ;
FloatNotation = 0 ;
WinFontSpecsSupported = 1 ;
TextAttachType = 0 ;
ShowUnits = False ;

Changes to
RTText = {
LabelText = "Anterior:" ;
FontName = "system default" ;
FontSize = -1.000000 ;
LabelActiveColor = 7 ;
BackgroundColor = 252 ;
ShowBackground = True ;
Justification = 0 ;
DataType = 0 ;
TotalDigits = 50 ;
DecimalPoints = 2 ;
InitiallyActive = True ;
RTEnable = False ;
RTPoint = "" ;
RTServer = "CMX" ;
DataQualityEnable = 3 ;
RTUnits = "" ;
ControlPanel = "" ;
FontHeightPct = 35.00000 ;
FloatNotation = 0 ;
WinFontSpecsSupported = 1 ;
TextAttachType = 0 ;
ShowUnits = False ;


But only if LabelText does NOT equal "Anterior:"

thanks