replaceing multiple lines

General discussions about Advanced Find and Replace
Post Reply
larryse
Posts: 7
Joined: Mon Sep 19, 2005 4:08 pm

replaceing multiple lines

Post 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

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

Yes, it's possible.
Please give us the samples:
source text and resulting text (after up replacements).
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

larryse
Posts: 7
Joined: Mon Sep 19, 2005 4:08 pm

Post 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

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post 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.
Last edited by Abacre on Wed Sep 21, 2005 6:00 pm, edited 1 time in total.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

larryse
Posts: 7
Joined: Mon Sep 19, 2005 4:08 pm

Post by larryse »

thanks Roman

larryse
Posts: 7
Joined: Mon Sep 19, 2005 4:08 pm

Post 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

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post 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 ;
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

larryse
Posts: 7
Joined: Mon Sep 19, 2005 4:08 pm

Post 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

Post Reply