expression to find a string in the middle of a word

expression to find a string in the middle of a word

6
NewbieNewbie
6

    Aug 11, 2015#1

    I can locate a string in Initial and Final position by using Ultraedit regex and by appending

    Code: Select all

    %

    Code: Select all

    $
    respectively
    How do I write a regex using Ultraedit syntax to identify a string in the middle of the word which is neither initial or medial
    example

    Code: Select all

    ue

    Code: Select all

    imbue
    imbued
    
    The regex should find only the second and not the first.
    I have a rather old version of Ultraedit 15.0
    Doing it Perl seems possible but the syntax is convoluted and my Ultraedit does not locate accurately the string
    Many thanks

    11327
    MasterMaster
    11327

      Aug 11, 2015#2

      Try

      Code: Select all

      ?+ue?+
      It's impossible to lead us astray for we don't care even to choose the way.

      6
      NewbieNewbie
      6

        Aug 11, 2015#3

        Thanks for the suggestion. It does locate the string but does not highlight/block them. I tried modifying the regex as under, but it still did not work

        Code: Select all

        ?+[ue]?+
        Whereas if you type a regex like

        Code: Select all

        ue$
        only ue will be highlighted and blocked. I need the block function to identify vowel strings in a database of Arabic. Hence the particular request.

        6,675585
        Grand MasterGrand Master
        6,675585

          Aug 11, 2015#4

          Use the Perl regular expression search string: (?<=\w)ue(?=\w)

          (?<=\w) ... is a positive look-behind expression for a word character according to definition of word characters in Unicode table (A-Za-z, digits, underscore and all language dependent word characters). A look-behind expression must be of fixed length like here for a single character. A look-behind expression never matches (selects) a string. It is just for verification if found string is in right context.

          (?=\w) ... is a positive look-ahead expression working exactly as look-behind, but in the other direction.

          So the entire expression means: find ue where character left of ue is a word character without selecting this character and character right of ue is also a word character without selecting this character.

          Note: The case-sensitivity of ue is controlled by Match case option in Find/Replace dialog/view.

          By the way: (?<!\w) is a negative look-behind for verification if character left to found string is NOT a word character and (?!\w) is a negative look-ahead for next character being NOT a word character. And take also a look at Readme for the Find/Replace/Regular Expressions forum with links to pages where more can be read about Perl regular expressions.
          Best regards from an UC/UE/UES for Windows user from Austria

          6
          NewbieNewbie
          6

            Aug 11, 2015#5

            Many thanks, not only for the regex but also for the clear explanation. You made my day!

              Aug 11, 2015#6

              Out of sheer curiosity, is there a way in which only the string to be searched is highlighted/blocked in UE. The solution provided by Mofi is great and identifies the string within the word but does not highlight/block the string which I am searching.
              Many thanks for providing a solution. From what I read, this does not seem possible. But there is nothing impossible is a regex and I am sure someone has answer.

              6,675585
              Grand MasterGrand Master
              6,675585

                Aug 11, 2015#7

                I don't understand your new question. In the example ue is the string to find in specific context (within a word). UltraEdit selects/highlights just ue and nothing else.

                So what do you mean with "does not highlight/block the string which I am searching"?
                Best regards from an UC/UE/UES for Windows user from Austria