Phil Pendlebury wrote:No takers on this one?
Hi Phil,
Interesting...
Yes it looks like in the MS Editor, using the Search/Replace feature, you can use a RegEx expression in the search field but not in the Replace field.
Specifically, the replace field will not recognize /1 as your first backreference which holds the matched line of interest.
I tried $1 as well for the backreference and it didn't work either so...
Marcus:
Q1) Can the Replace field be enhanced so that it does understand a backreference when Options/Regular expressions is checked?
Q2) In the Search/Replace Dialog, under Options, there is a checkbox called "Replace with template" which is greyed out if "Regular expressions" is not checked. What is that and how do we use it? I could not find anything on it in the Help File by searching for the word "template".
Ahh well... until then Phil... you can certainly do this with a script.
See below and enjoy!
Code: Select all
LabelToVar>LINES,myLINES
/*
LINES:
FindImagePos>blah.bmp,glah.bmp,%tol%,1,XArr,YArr,numfound
Another one of Phil's script lines
FindImagePos>blah.bmp,glah.bmp,%tol%,1,XArr,YArr,numfound
Yet another one of Phil's script lines
FindImagePos>blah.bmp,glah.bmp,%tol%,1,XArr,YArr,numfound
*/
//For your viewing pleasure - just makes the message box a little wider
Let>MSG_WIDTH=425
MDL>myLINES
//We will add this text onto the end of each of our target lines.
//This allows us to "bury" the , which would otherwise confuse
//the RegEx line below because commas are used to separate parameters.
Let>add_on=,CCOEFF
//See: http://www.regular-expressions.info/brackets.html
//Round Brackets in your RegEx pattern create a Backreference we can take advantage of later
//text matched inside first set of (round brackets) is stored in Backreference $1
//text matched inside second set of (round brackets) is stored in Backreference $2 and so on...
//The first set of (round brackets) in pattern do not create a backreference, (?m) just turns multiline mode on
//Our target text line will be captured into backreference $1
Let>pattern=(?m)^( *FindImagePos>[^\x0D\x0A]*)
//Now when we replace, we replace with $1 and %add_on% right after it
RegEx>pattern,myLINES,0,matches,num,1,$1%add_on%,myLINES
MDL>myLINES