Tapatalk

How to choose optional characters? (?) doesn't work.

How to choose optional characters? (?) doesn't work.

5
NewbieNewbie
5

    Mar 17, 2005#1

    I have a test text file which contains these 3 lines:
    color colour
    color
    colour

    When I use "Find", I use Unix Regular Expressions. I have the latest UltraEdit (ver 11).
    I want to use "Find" to search for the word "color" and optionally "colour". So I put "colou?r" in the search box and the search finds nothing. If I go outside of UltraEdit and use egrep in a DOS box (egrep -i colou?r <filename>) then it works fine and finds both words.
    Apparently the ? metacharacter does not work in UltraEdit. How would I perform such an optional search in UltraEdit? Thank you!

    206
    MasterMaster
    206

      Mar 17, 2005#2

      Maybe colo*r
      Software For Metalworking
      http://closetolerancesoftware.com

      5
      NewbieNewbie
      5

        Mar 18, 2005#3

        Mrainey, you are amazing! What you suggested worked great. I guess what your code says is "none or more of the preceding character".
        I've read Freidl's book on Regular Expressions and have picked it up again since discovering I can use Unix RegEx's in UltraEdit. It's cool to see them work as you go through the text file.
        And I'm happy that you have shown me how to use something I'll use a lot. Thank you!

          Mar 18, 2005#4

          One thing I did notice about using "colo*r" is that it will also pick up "colouuuuuur". It doesn't appear to be an issue now and I hope I will see how to get around it as I review Friedl's book. It appears UltraEdit needs to add the "?" feature to it's Unix Regular Expressions, but I'm not educated enough on the subject to say for sure.

          206
          MasterMaster
          206

            Mar 18, 2005#5

            You'll find that the UE implementation of regular expressions is missing a number of capabilities you'll read about in your book.

            Most of the time you can figure out a way to make the UE regex do what you want.
            Software For Metalworking
            http://closetolerancesoftware.com

            5
            NewbieNewbie
            5

              Mar 18, 2005#6

              Yes, I think you are right, that I will most of the time find what I need with UltraEdit's RegEx. I'm going to keep using it for much of my file search and replace and other repair. I need to find something that I can use when I need to do heavyweight RegEx stuff, but I have not found a tool yet that works consistently.

              I want to thank you again for your outstanding help!