Match By Whole Word Under Perl Regex

Match By Whole Word Under Perl Regex

2
NewbieNewbie
2

    Dec 13, 2010#1

    I tried to search for symbol characters using Perl style regex e.g.

    Code: Select all

    ]
    for searching a bracket. If i disable Match Whole Word Only, I can match a standalone ] character. But if I enable it, the ] cannot be matched. This is observed when searching for many different kinds of symbol characters (* " etc). What is wrong with it?

    I just want to initialize the findReplace parameters to a single consistent set of values (perl regex, matching whole word, etc) and change my search string only for various cases. Does it mean I should not use match by whole word when regex used?

    901
    MasterMaster
    901

      Dec 13, 2010#2

      In regular expressions, a word consists of consecutive alpha-numeric characters and underscores. Everything else (including the square bracket) serves as a delimiter. Enclosing a stand-alone delimiter in word boundary markers will cause the search to fail.

      It is possible to search for words only in a Perl regular expression simply by putting a \b on both sides of your search string. I expect that is what UE does in the background when the "Match Whole Word Only" option is enabled. If you disable "Match Whole Word Only" and search for \b]\b it fails as well.

      To answer your question: When using regular expressions it is good practice to leave "Match Whole Word Only" disabled and simply wrap your search criteria in \b characters when you want to search with word boundaries. In some editors, the "Match Whole Word Only" setting is grayed out (not even available) when regular expressions are being used.

      6,681583
      Grand MasterGrand Master
      6,681583

        Dec 14, 2010#3

        Just a small addition to what Bulgrien already wrote:

        Match Whole Word Only is designed mainly for simple, non regular expression text searches where a specified text should be found only when it is a complete word and not part of another word. This option can be also used in UltraEdit or Unix regular expression searches which do not support \b or \< or \> as available in Perl regular expressions, if the UE/Unix regular expression is used to find words consisting of characters in character set [0-9A-Za-z_]. But for Perl regular expression searches this option should not be used because Perl regexp engine supports word boundary checks.

        An example for using Match Whole Word Only together with a regular expression search would be searching for i[a-z]+ and only words should be found starting with letter i. With Match Whole Word Only this search string would find iVar, but not dwVariable. Without this option the regular expression would also find the red highlighted part of the second variable name.
        Best regards from an UC/UE/UES for Windows user from Austria