Loading ...
Sorry, an error occurred while loading the content.

Search and replace Regular Expression

Expand Messages
  • Steve B
    I am a complete greenhorn with reg exp so sorry if this has been answered or its a stupid question. I want to replace all occurences of
    Message 1 of 8 , Jul 18, 2009
    View Source
    • 0 Attachment
      I am a complete greenhorn with reg exp so sorry if this has been answered or its a stupid question.

      I want to replace all occurences of

      LOwerCaseletter^PLOwerCaseletter with
      LOwerCaseletterSPACELOwerCaseletter

      When i do a save as *.txt of a pdf file the txt shows up as

      This is a really
      really long sentence
      that
      doesnt say
      much.

      I want it to say

      This is a really really long sentence that doesnt say much.

      Is there an online tutorial somewhere?

      Thanks
    • Don - HtmlFixIt.com
      replace this ([a-z]) r n([a-z]) with this $1 $2 Putting something in () means it is captured as a subpattern that can then be put back in the replace. [a-z] is
      Message 2 of 8 , Jul 18, 2009
      View Source
      • 0 Attachment
        replace this
        ([a-z])\r\n([a-z])
        with this
        $1 $2

        Putting something in () means it is captured as a subpattern that can
        then be put back in the replace.

        [a-z] is a lowercase letter
        \r\n is a return character

        so you are looking for lower case letter followed by a return and then
        replacing it with the same lower case letter, a space, the same lower
        case letter

        You can do it with a clip or search and replace.

        Steve B wrote:
        > I am a complete greenhorn with reg exp so sorry if this has been answered or its a stupid question.
        >
        > I want to replace all occurences of
        >
        > LOwerCaseletter^PLOwerCaseletter with
        > LOwerCaseletterSPACELOwerCaseletter
        >
        > When i do a save as *.txt of a pdf file the txt shows up as
        >
        > This is a really
        > really long sentence
        > that
        > doesnt say
        > much.
        >
        > I want it to say
        >
        > This is a really really long sentence that doesnt say much.
        >
        > Is there an online tutorial somewhere?
        >
        > Thanks
        >
        >
        >
        >
        >
        >
        > ------------------------------------
        >
        > Fookes Software: http://www.fookes.com/
        > NoteTab website: http://www.notetab.com/
        > NoteTab Discussion Lists: http://www.notetab.com/groups.php
        >
        > ***
        > Yahoo! Groups Links
        >
        >
        >
        >
      • Sheri
        ... Try this, should also work from the replace dialog. ^!Replace (?-i)[a-z] K x20*$ R x20 RAWS0 It says: (?-i) not case insensitive [a-z] a character
        Message 3 of 8 , Jul 18, 2009
        View Source
        • 0 Attachment
          --- In ntb-scripts@yahoogroups.com, "Steve B" <kalukee@...> wrote:
          >
          > I am a complete greenhorn with reg exp so sorry if this has been answered or its a stupid question.
          >
          > I want to replace all occurences of
          >
          > LOwerCaseletter^PLOwerCaseletter with
          > LOwerCaseletterSPACELOwerCaseletter
          >
          > When i do a save as *.txt of a pdf file the txt shows up as
          >
          > This is a really
          > really long sentence
          > that
          > doesnt say
          > much.
          > I want it to say
          >
          > This is a really really long sentence that doesnt say much.
          >

          Try this, should also work from the replace dialog.

          ^!Replace "(?-i)[a-z]\K\x20*$\R" >> "\x20" RAWS0

          It says:

          (?-i) not case insensitive
          [a-z] a character that is in the range of lower case a-z
          \K says leave out the part preceding when forming the match that will get replaced (iow, leave the lower case a-z character)
          \x20* would match any number (or zero) spaces
          $ matches at the end of a line (but consumes no characters)
          \R matches the line breaking characters that follow the end of the line

          "\x20" is hex for one space.

          It is only going to replace any empty spaces and line breaking characters provided that they follow a lower case letter.

          Actually to precisely do what you asked could be done with:

          ^!Replace "(?-i)[a-z]$\K\R([a-z])" >> "\x20$1" RAWS0

          Then it doesn't worry about possibly empty spaces at line ends and requires a lower case letter after the line break, which it captures as $1 for the replacement.

          >
          > Is there an online tutorial somewhere?

          Hmmn, a link that I had for a good tutorial isn't working anymore. I will see if I can find my copy of the file and if so will post it in the files area of this group. However, the most uptodate info on the version of PCRE regex supported by NoteTab is in the regex.chm file in the NoteTab application folder.

          Regards,
          Sheri
        • Don - HtmlFixIt.com
          I have the tutorial you sent a while back Sheri, it is a microsoft powerpoint or something, but I made a text copy I use myself :-) K is my learning for the
          Message 4 of 8 , Jul 18, 2009
          View Source
          • 0 Attachment
            I have the tutorial you sent a while back Sheri, it is a microsoft
            powerpoint or something, but I made a text copy I use myself :-)

            \K is my learning for the day I guess ... wow, so that essentially
            leaves everything before the \K untouched on replacement?

            Is notetab case insensitive by default so that we should use the -i?


            > Actually to precisely do what you asked could be done with:
            >
            > ^!Replace "(?-i)[a-z]$\K\R([a-z])" >> "\x20$1" RAWS0
            >
            > Then it doesn't worry about possibly empty spaces at line ends and requires a lower case letter after the line break, which it captures as $1 for the replacement.
            >
            >> Is there an online tutorial somewhere?
            >
            > Hmmn, a link that I had for a good tutorial isn't working anymore. I will see if I can find my copy of the file and if so will post it in the files area of this group. However, the most uptodate info on the version of PCRE regex supported by NoteTab is in the regex.chm file in the NoteTab application folder.
            >
          • Sheri
            ... Found it (newer date, but looks about the same as the older one I had):
            Message 5 of 8 , Jul 19, 2009
            View Source
            • 0 Attachment
              --- In ntb-scripts@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
              > > Is there an online tutorial somewhere?
              >
              > Hmmn, a link that I had for a good tutorial isn't working
              > anymore. I will see if I can find my copy of the file and if so
              > will post it in the files area of this group. However, the most
              > uptodate info on the version of PCRE regex supported by NoteTab
              > is in the regex.chm file in the NoteTab application folder.

              Found it (newer date, but looks about the same as the older one I had):

              <http://gravitonic.com/c/dl.php?file=talks/php-quebec-2009/regex-clinic.pdf>

              Regards,
              Sheri
            • Steve B
              thanks for the replies, i am still digesting what was given.:)
              Message 6 of 8 , Jul 19, 2009
              View Source
              • 0 Attachment
                thanks for the replies, i am still digesting what was given.:)


                --- In ntb-scripts@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
                >
                > --- In ntb-scripts@yahoogroups.com, "Sheri" <silvermoonwoman@> wrote:
                > > > Is there an online tutorial somewhere?
                > >
                > > Hmmn, a link that I had for a good tutorial isn't working
                > > anymore. I will see if I can find my copy of the file and if so
                > > will post it in the files area of this group. However, the most
                > > uptodate info on the version of PCRE regex supported by NoteTab
                > > is in the regex.chm file in the NoteTab application folder.
                >
                > Found it (newer date, but looks about the same as the older one I had):
                >
                > <http://gravitonic.com/c/dl.php?file=talks/php-quebec-2009/regex-clinic.pdf>
                >
                > Regards,
                > Sheri
                >
              • Alec Burgess
                Steve: I ll bet your mind is reeling, especially if you tried to digest everything in Sheri s excellent reference PDF in one pass. Another you might want to
                Message 7 of 8 , Jul 19, 2009
                View Source
                • 0 Attachment
                  Steve: I'll bet your mind is reeling, especially if you tried to digest
                  everything in Sheri's excellent reference PDF in one pass.
                  Another you might want to have a look at (less scrolling and repetition)
                  but denser presentation is: http://www.regular-expressions.info/

                  Its the "I'm feeling lucky"(#1 hit) if you just google [regular expressions]
                  In fact it's #1 on all of the big three Google, Bing and Yahoo (check
                  with http://blindsearch.fejus.com/ ) 8-)
                  <aside> I wonder how Jan Goyvaerts, author of RegexBuddy, managed to
                  establish and maintain that position? </aside>

                  I just want to point out that your original question (joining split
                  lines back into one) can be handled in Notetab by menu-Modify-Lines-Join
                  Lines (aka Ctrl+J) and well worth putting its button on your toolbar.
                  Just select the lines you want joined and issue Ctrl+J or select
                  multiple groups of split lines separated by blank lines and do them all
                  with one key press.

                  That said, I hope you continue with exploring regular expressions - once
                  you achieve a little bit of comfort with them you'll find many other
                  programs in addition to Notetab where they can be used.

                  Steve B (kalukee@...) wrote (in part) (on 2009-07-19 at 12:23):
                  > thanks for the replies, i am still digesting what was given.:)
                  >
                  > --- In ntb-scripts@yahoogroups.com, "Sheri" <silvermoonwoman@...>
                  > wrote:
                  > >
                  > > --- In ntb-scripts@yahoogroups.com, "Sheri" <silvermoonwoman@>
                  > wrote:
                  > > > > Is there an online tutorial somewhere?
                  > > >
                  > > > Hmmn, a link that I had for a good tutorial isn't working
                  > > > anymore. I will see if I can find my copy of the file and if so
                  > > > will post it in the files area of this group. However, the most
                  > > > uptodate info on the version of PCRE regex supported by NoteTab
                  > > > is in the regex.chm file in the NoteTab application folder.
                  > >
                  > > Found it (newer date, but looks about the same as the older one I
                  > had):
                  > >
                  > >
                  >
                  <http://gravitonic.com/c/dl.php?file=talks/php-quebec-2009/regex-clinic.pdf>

                  --
                  Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)




                  [Non-text portions of this message have been removed]
                • Art Kocsis
                  Hello Steve, A month ago I posted an extensive list and discussion of RegEx resources on the NoteTab Clips group: Date: Fri, 04 Sep 2009 23:57:46 -0700
                  Message 8 of 8 , Oct 7, 2009
                  View Source
                  • 0 Attachment
                    Hello Steve,

                    A month ago I posted an extensive list and discussion of RegEx
                    resources on the NoteTab Clips group:

                    Date: Fri, 04 Sep 2009 23:57:46 -0700
                    Subject: [Clip] RegEx Resources
                    http://tech.groups.yahoo.com/group/ntb-clips/message/19616

                    There are links to tutorials that are understandable by newbies. I found
                    them to be very helpful and also good refreshers. The built-in NoteTab
                    RegEx help file is basically a regurgitation of the official RegEx spec
                    written by Philip Hazel. It was written as a reference document, not as
                    a tutorial and assumes you already know what a RegEx is.

                    The Perl.org tutorials start from the basic "hello world" level and have
                    lots of examples. Just ignore the Perl specific syntax and absorb the
                    RegEx info. The perlrequick document is a good tool to print out and
                    keep handy.

                    To the Group: I suspect I am not the only one who didn't realize (or
                    forgot), that this is one of two overlapping NoteTab groups on Yahoo.
                    This one (NoteTab Scripts) seems to have almost the same agenda
                    as NoteTab Clips. Both deal with clips and both deal with RegEx.

                    Why two groups??? It's been years since I set up my email filters so
                    any distinction is long lost and I have been operating on automatic
                    ever since. It would seem that, short of dual posting, a lot of info and
                    interested audience is lost. I would guess that not every one is signed
                    up with both groups.

                    Namaste', Art

                    At 07-18-2009 08:21, you wrote:
                    >I am a complete greenhorn with reg exp so sorry if this has been answered
                    >or its a stupid question.
                    <snip>

                    >Is there an online tutorial somewhere?
                    >
                    >Thanks

                    ----------


                    No virus found in this outgoing message.
                    Checked by AVG - www.avg.com
                    Version: 8.5.421 / Virus Database: 270.14.5/2419 - Release Date: 10/07/09 05:18:00


                    [Non-text portions of this message have been removed]
                  Your message has been successfully submitted and would be delivered to recipients shortly.