Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6516
    nickb
    Member

    Hello,

    I downloaded the script from http://www.emeditor.com/modules/mydownloads/singlefile.php?cid=8&lid=169 and when using it I noticed that it treats lower cases and capital letters different.

    example:
    If you have a list…
    hello
    Hello
    heLLo

    You use the script to extract ‘hello’, you will only get the ‘hello’ with the lower cases.

    How can I change this so the script treats all letters equal?



    if( !editor.EnableTab ){
    editor.EnableTab = true;
    alert( "Please run this macro again." );
    Quit();
    }

    sFind = prompt( "This macro extracts lines that do contain the specified string:", "" );
    if( sFind == "" ){
    Quit();
    }

    Redraw = false;

    docSearch = editor.ActiveDocument;
    editor.NewFile();
    docResult = editor.ActiveDocument;
    docSearch.Activate();

    docSearch.selection.StartOfDocument();
    y = 1;
    do {
    docSearch.selection.SetActivePoint( eePosLogical, 1, y );
    if( y != docSearch.selection.GetActivePointY( eePosLogical ) ) break;
    docSearch.selection.SelectLine();
    sLine = docSearch.selection.Text;
    re = new RegExp( ".*" + sFind + ".*" );
    result = re.test( sLine );
    if( result ){
    docResult.Activate();
    docResult.selection.Text = sLine;
    }
    docSearch.Activate();
    y++;
    } while( true );

    thanks!

    #6524
    dreftymac
    Participant

    Hello nickb,

    Try taking the line that says:

    re = new RegExp( “.*” + sFind + “.*” );

    … and change it to this …

    re = new RegExp( “.*” + sFind + “.*” , “i”);

    This should tell the regular expression matcher to ignore case.

    For more details see :
    http://www.regular-expressions.info/javascript.html
    or search microsoft.com for “jscript reference” “regexp”

    HTH

    #6526
    nickb
    Member

    Thanks, dreftymac ! Now it works. :-)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.