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

Need help with "consider case" for regexp searches

Contributor ,
Aug 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

With assistance of forum's Frame Master I've be able to implement the code below to search for regexps. However, I can't seem to set the Consider Case parameter.  I remember an earlier piece of code posted by K. Daube that used qFlags, but I'm not familiar with how they work. Rick mentioned adding an "ig" or "g" to set the global flag at the end of the experession, but it seems to just stip that off when I try passing that to the function. Thoughts?

 

regex = "Widget";
getRegexFindParams (regex)

function getRegexFindParams (regex) { //CP.getRegexFindParams = function (regex) {

doc=app.ActiveDoc;
docStart = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
tloc = new TextLoc (docStart, 0);

findParams = new PropVals ();

propVal = new PropVal ();
propVal.propIdent.num = Constants.FS_FindText;
propVal.propVal.valType = Constants.FT_String;
propVal.propVal.sval = regex;
findParams[0] = propVal;

propVal = new PropVal ();
propVal.propIdent.num = Constants.FS_FindCustomizationFlags;
propVal.propVal.valType = Constants.FT_Integer;
propVal.propVal.ival = 16; // Regular expressions
findParams[1] = propVal;

propVal = new PropVal ();
propVal.propIdent.num = Constants.FS_FindWrap;
propVal.propVal.valType = Constants.FT_Integer;
propVal.propVal.ival=0;
findParams[2] = propVal;

propVal = new PropVal ();
propVal.propIdent.num = Constants.FS_RegexFlavour;
propVal.propVal.valType = Constants.FT_Integer;
propVal.propVal.ival = 1;
findParams[3] = propVal;

foundText = doc.Find(tloc, findParams);
//background highlight found text and get next

Views

82

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

correct answers 1 Correct answer

Community Expert , Aug 09, 2022 Aug 09, 2022

The customisation flags must be "ored". The following snippet may help you (bWord is true if only full words are to be considere, bCase etc. analogous):

  if (bWord || bCase || bBack || bRegEx || bWild) { 
    oPropVal3 = new PropVal() ;
    oPropVal3.propIdent.num = Constants.FS_FindCustomizationFlags ;
    oPropVal3.propVal.valType = Constants.FT_Integer;
    qFlags = 0;
    if (bCase)  { qFlags = qFlags   | Constants.FF_FIND_CONSIDER_CASE;} // 0x01
    if (bRegEx) { qFlags = qFlags   | Consta
...

Votes

Translate

Translate
Community Expert ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

The customisation flags must be "ored". The following snippet may help you (bWord is true if only full words are to be considere, bCase etc. analogous):

  if (bWord || bCase || bBack || bRegEx || bWild) { 
    oPropVal3 = new PropVal() ;
    oPropVal3.propIdent.num = Constants.FS_FindCustomizationFlags ;
    oPropVal3.propVal.valType = Constants.FT_Integer;
    qFlags = 0;
    if (bCase)  { qFlags = qFlags   | Constants.FF_FIND_CONSIDER_CASE;} // 0x01
    if (bRegEx) { qFlags = qFlags   | Constants.FF_FIND_USE_REGEX;      // 0x10
        oPropVal4 = new PropVal ();
        oPropVal4.propIdent.num = Constants.FS_RegexFlavour;            // 17
        oPropVal4.propVal.valType = Constants.FT_Integer;
        oPropVal4.propVal.ival = Constants.FR_USE_PERL;                 // 1
        findParms.push(oPropVal4);
    } else {
      if (bWild)  { qFlags = qFlags | Constants.FF_FIND_USE_WILDCARDS;} // 0x04
      if (bWord)  { qFlags = qFlags | Constants.FF_FIND_WHOLE_WORD;}    // 0x02
      if (bBack)  { qFlags = qFlags | Constants.FF_FIND_BACKWARDS;}     // 0x08
    }
    oPropVal3.propVal.ival = qFlags; // qFlags OK; ...ival reports error in ESTK
    findParms.push(oPropVal3);

 

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
Contributor ,
Aug 13, 2022 Aug 13, 2022

Copy link to clipboard

Copied

LATEST

Sorry...disregard my previous.  I see you already provide me the answer.  I had forgotten this post. 

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