• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Find/Replace: which Regex flavours are really used?

Community Expert ,
Oct 17, 2020 Oct 17, 2020

Copy link to clipboard

Copied

Barb Binder triggered my interest in creating an equivalent Find/Replace for FM (see here).

I have an idea of an UI which allows to insert Regex elements by selection from panel with drop down etc.. This shall be opened on click on the button RegEx:

find-replace-extended.png

BTW it seems that FM does not check the validity of a RegEx: 

^([IVX]+)(.

does not create an error message if used for Find. FM just tells “Nothing found” The error is obvious: a mismatch in parentheses.

FM provides three flavours of RegEx syntax; Perl (the default), Grep and Egrep (enhanced Grep). There is a t least one significant difference betwee these flavours: handling of line breaks in the dot operator (any character). See the extensive discussion of this in the RegExBuddy by Jan Goyvaerts .

Therefore it is (for all but simple cases) necessary to know what is implemented (in FM. BTW ExtendScript Scripting guide and FDK reference / programmer’s guide do not know “Regular Expression” nor “regex”).

FM help tells about these flavours:

Perl: perldoc.perl.org, grep: www.robelle.com,  egrep www.gnu.org

The help text itself concentrates on the basic RegEx features which have equal syntax in all three flavours (and BTW contains errors).

With all these ambiguities I may end up with this solution:

My questions now:

  • What do you think about the whole idea?
  • Which RegEx flavour is really used by You?
  • Is it necessary to support all three flavours by the select/insert function mentioned before?
  • Which Versions of Perl, Grep or Egrep are implemented? FM help refers to the Boost library where a number of versiona are available.
  • Is it required that RegEx related information is localised? IMHO the linjgua franca in programming is English…

Views

218

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 17, 2020 Oct 17, 2020

Copy link to clipboard

Copied

Hi Klaus:

 

  • What do you think about the whole idea?

I love that you are taking a look at this. I rely on Regex queries to quickly clean up and standardize my FrameMaker documents and—as stated on the other thread—I keep the list that I have developed in a Word doc that I copy/paste over, since they drop off the bottom of the last used lists.

 

  • Which RegEx flavour is really used by You?

That said, I have no idea which flavor I am actually using, though I am assuming GREP. I have worked through a LinkedIn Learning course on GREP/InDesign and through @Peter Kahrel's excellent GREP in InDesign book. Because InDesign is so much further along with the GREP interface, we get a fair number of GREP inquiries on the InDesign forum and have very talented folks who address these questions. I ask them to clarify their answers if I couldn't answer it on my own, so I'm learning as I go. Regex/GREP does not come naturally to me, but I'm motivated to improve because I am always trying to reduce the time required to get a job out the door, and this is a powerful tool in my toolbox. 

 

Now, I have the impression that this feature is largely ignored by the FrameMaker community, so I'm eager to see how other folks answer your questions. Maybe they will prove me wrong and it's being used more than I think.

 

~Barb 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

Hi Klaus,

 

Very good! When I use regular expressions, I just use the default Perl variant. I do not use regular expressions very often, about once a month. However, when I use them, they are very, very helpful!

In my oppinion the English interface is fine for such an extended Find/Replace. My FrameMaker interface is English anyway.

I do not have RegEx Buddy. I learned regular expressions more than 20 years ago, when I worked with FrameMaker on Unix. However, my knowledge is limited.

 

Suggestion: Add a field which shows how the selected text would be changed.

 

Best regards

 

Winfried

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

LATEST

Hi Winfried.

«Suggestion: Add a field which shows how the selected text would be changed.»

IMHO for a selection this would be a preview of the result? Might be difficult, because I intend to use the Find/Replace mechanism of ES as I used it in various other scripts. The following are just snippings from such a script:

  findParams = GetFindParams (findString);    // Get the find parameters ... these will vary
  InitFA_errno ();                            // reset - it is write protected
  tr = targetDoc.Find(tr.beg, findParams);    // and do an initial find to get started.
  while(FA_errno === Constants.FE_Success && loopCounter++ < 2*loopMax) { 
    targetDoc.TextSelection = tr;             // set up the TRto clear the original text
    targetDoc.Clear(0);                       // clear it
    app.ActiveDoc = sourceDoc;                // switch to sourceDoc
    sourceDoc.TextSelection = trReplace;      // to be able to get the replacement text
    sourceDoc.Copy(0);
    app.ActiveDoc = targetDoc;                // switch to targetDoc
    targetDoc.Paste(0);                       // and paste the replacement text
    ReApplyFontAndSize (targetDoc,            // re-apply the current para format
    if(FA_errno === Constants.FE_Success) {  // increment our return counter - does not work
      replacementCounter++;
    }
    InitFA_errno ();                          // used to track the progress of the f/r
    tr = targetDoc.Find(tr.beg, findParams);  // something screwy happened ...
  }

But I'm just at the beginning of 'punchinging the fog'.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines