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

VERY difficult RegEX, Help!

Expand Messages
  • John Morse
    Hello editplus, I am in need of some help, I know I need mental help, but for now, i just need help with a difficult reg expression search and replace. I have
    Message 1 of 7 , Nov 25, 2004
    • 0 Attachment
      Hello editplus,

      I am in need of some help, I know I need mental help, but for now, i
      just need help with a difficult reg expression search and replace.
      I have many files that I need to search through and find all
      occurances of (for example)
      Ex 6:13, 16-20
      Ex 2:1-4; 7:7

      and change them to
      {\cf11\ul Exo_6:13}, {\cf11\ul Exo_6:16-20}
      {\cf11\ul Exo_2:1-4}; {\cf11\ul Exo_2:7:7}

      I thought maybe If I could break them up into steps, like first
      change all the instances like this (Ex 6:13, 16-20) to this
      (Ex 6:13, Ex 6:16-20) notice how the verses are nested and needs to have the chapter
      before it in every instance.

      Then If I could figure out a reg ex that will change (Ex 6:13, Ex 6:16-20)
      to (Exo_6:13, Exo_6:16-20)
      Then I could finish up by using a reg ex that will look for either
      Exo_6:13 or Exo_6:16-20 and wrap them with {\cf11\ul scripturehere}
      like this {\cf11\ul Exo_6:16-20}

      I know this is very difficult, and time consuming, but...
      If anyone could help me with this i would be very appreciative. In
      fact I will even send you a very old (but still usable) straight
      razor from my personal collection! It will be honed and stropped by
      me and will give you a good shave for a lifetime.

      thanks in advance!

      --
      ~John

      {He who trims himself to suit everyone will soon whittle himself away }

      The_Bat! Version 3.0.2.5
      http://www.ritlabs.com
      PowerPro, the ultimate power tool!
      http://powerpro.webeddie.com
      EditPlus2, the ultimate editor!
      http://www.editplus.com
    • Christoph P├Ąper
      ... s1: (Ex) ([0-9]+:[0-9]+)(, )([0-9]+-[0-9]+) s2: (Ex) ([0-9]+:[0-9]+-[0-9]+)(; )([0-9]+:[0-9]+) r: { cf11 ul 1o_ 2} 3{ cf11 ul 1o_ 4)} Plusses assumed.
      Message 2 of 7 , Nov 25, 2004
      • 0 Attachment
        *John Morse* <john_morse@...>:
        >
        > Ex 6:13, 16-20
        > Ex 2:1-4; 7:7
        >
        > {\cf11\ul Exo_6:13}, {\cf11\ul Exo_6:16-20}
        > {\cf11\ul Exo_2:1-4}; {\cf11\ul Exo_2:7:7}

        s1: (Ex) ([0-9]+:[0-9]+)(, )([0-9]+-[0-9]+)
        s2: (Ex) ([0-9]+:[0-9]+-[0-9]+)(; )([0-9]+:[0-9]+)
        r: {\cf11\ul \1o_\2}\3{\cf11\ul \1o_\4)}

        Plusses assumed.

        Maybe you can combine both searches, but you didn't give enough detail for
        me to know. Maybe:

        s: (Ex|Foo|Bar) ([0-9]+:[0-9]+(-[0-9]+)?)([,;] )([0-9]+[-:][0-9]+)
        r: {\cf11\ul \1o_\2\3}\4{\cf11\ul \1o_\5)}

        That's not yet a difficult one.
      • John Morse
        It messes up on these Ex 32:26-30; 34:31-34; 35:1, 4 Ex 29:10-46; 30:26-38 ] Ex 31:2-6; 35:34; 38:23 It also turns this: Ex 24:1, 9-11 into this: { cf11 ul
        Message 3 of 7 , Nov 25, 2004
        • 0 Attachment
          It messes up on these
          Ex 32:26-30; 34:31-34; 35:1, 4
          Ex 29:10-46; 30:26-38 ]
          Ex 31:2-6; 35:34; 38:23

          It also turns this:
          Ex 24:1, 9-11
          into this:
          {\cf11\ul Exo_24:1}, {\cf11\ul Exo_9-11)}
          [it needs to have the chapter 24: in the above instance Exo_24:9-11]
          I really appreciate it!!!! I thought it would be much harder than
          this.

          Thursday, November 25, 2004, 1:42:52 PM, you wrote:

          CP> *John Morse* <john_morse@...>:
          >>
          >> Ex 6:13, 16-20
          >> Ex 2:1-4; 7:7
          >>
          >> {\cf11\ul Exo_6:13}, {\cf11\ul Exo_6:16-20}
          >> {\cf11\ul Exo_2:1-4}; {\cf11\ul Exo_2:7:7}

          CP> s1: (Ex) ([0-9]+:[0-9]+)(, )([0-9]+-[0-9]+)
          CP> s2: (Ex) ([0-9]+:[0-9]+-[0-9]+)(; )([0-9]+:[0-9]+)
          CP> r: {\cf11\ul \1o_\2}\3{\cf11\ul \1o_\4)}

          CP> Plusses assumed.

          CP> Maybe you can combine both searches, but you didn't give enough detail for
          CP> me to know. Maybe:

          CP> s: (Ex|Foo|Bar) ([0-9]+:[0-9]+(-[0-9]+)?)([,;] )([0-9]+[-:][0-9]+)
          CP> r: {\cf11\ul \1o_\2\3}\4{\cf11\ul \1o_\5)}

          CP> That's not yet a difficult one.



          CP> http://www.editplus.com
          CP> http://groups.yahoo.com/group/editplus
          CP> Yahoo! Groups Links
        • Jannetta Lewis
          Hi John I might be a bit late, but this might still help. This one seems to work for the first replacement: s1: (Ex) ([0-9]+:)([0-9]+[-0-9]*)([,|;]*)
          Message 4 of 7 , Nov 26, 2004
          • 0 Attachment
            Hi John

            I might be a bit late, but this might still help.

            This one seems to work for the first replacement:
            s1: (Ex) ([0-9]+:)([0-9]+[-0-9]*)([,|;]*)
            ([0-9]+[-|:]*[0-9]+[-0-9]*[,]*)*
            r: {\cf11\ul \1o_\2\3\4} {\cf11\ul Exo_\2\5}


            This will replace a few more cases after the first, but it not refined
            yet. Unfortunately I can't spend any more time to try and help.
            s2: ([0-9]+)([-|:]*[0-9]+[-0-9]*)([ ,]+)([0-9]*[-0-9]*)
            r: {\cf11\ul Exo_\1\2}\2{\cf11\ul Exo_\1:\4}

            Hope it helps

            Jannetta


            ====
            New College Durham
            Product Development Co-ordinator
            X4434

            "Time is an illusion. Lunchtime doubly so." (Ford Prefect)
            "The difference between genius and stupidity is genius has its limits"
            (Albert Einstein)

            >>> john_morse@... 25/11/2004 22:40:32 >>>
            It messes up on these
            Ex 32:26-30; 34:31-34; 35:1, 4
            Ex 29:10-46; 30:26-38 ]
            Ex 31:2-6; 35:34; 38:23

            It also turns this:
            Ex 24:1, 9-11
            into this:
            {\cf11\ul Exo_24:1}, {\cf11\ul Exo_9-11)}
            [it needs to have the chapter 24: in the above instance Exo_24:9-11]
            I really appreciate it!!!! I thought it would be much harder than
            this.

            Thursday, November 25, 2004, 1:42:52 PM, you wrote:

            CP> *John Morse* <john_morse@...>:
            >>
            >> Ex 6:13, 16-20
            >> Ex 2:1-4; 7:7
            >>
            >> {\cf11\ul Exo_6:13}, {\cf11\ul Exo_6:16-20}
            >> {\cf11\ul Exo_2:1-4}; {\cf11\ul Exo_2:7:7}

            CP> s1: (Ex) ([0-9]+:[0-9]+)(, )([0-9]+-[0-9]+)
            CP> s2: (Ex) ([0-9]+:[0-9]+-[0-9]+)(; )([0-9]+:[0-9]+)
            CP> r: {\cf11\ul \1o_\2}\3{\cf11\ul \1o_\4)}

            CP> Plusses assumed.

            CP> Maybe you can combine both searches, but you didn't give enough
            detail for
            CP> me to know. Maybe:

            CP> s: (Ex|Foo|Bar) ([0-9]+:[0-9]+(-[0-9]+)?)([,;] )([0-9]+[-:][0-9]+)
            CP> r: {\cf11\ul \1o_\2\3}\4{\cf11\ul \1o_\5)}

            CP> That's not yet a difficult one.



            CP> http://www.editplus.com
            CP> http://groups.yahoo.com/group/editplus
            CP> Yahoo! Groups Links










            http://www.editplus.com
            http://groups.yahoo.com/group/editplus


            Yahoo! Groups Sponsor


            Get unlimited calls to
            U.S./Canada
            Yahoo! Groups Links
            To visit your group on the web, go to:
            http://groups.yahoo.com/group/editplus/
            To unsubscribe from this group, send an email to:
            editplus-unsubscribe@yahoogroups.com
            Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


            --
            This message has been scanned for viruses and dangerous
            content by the NorMAN MailScanner Service and is believed
            to be clean.

            The NorMAN MailScanner Service is operated by Information
            Systems and Services, University of Newcastle upon Tyne.
          • DZ-Jay
            These will work: s: Ex +([0-9]+):([0-9-]+)([,;]) +([0-9:-]+) r: { cfll ul Exo_ 1: 2} 3 { cfll ul Exo_ 1: 4} But they will only work for examples like the ones
            Message 5 of 7 , Nov 26, 2004
            • 0 Attachment
              These will work:
              s: Ex +([0-9]+):([0-9-]+)([,;]) +([0-9:-]+)
              r: {\cfll\ul Exo_\1:\2}\3 {\cfll\ul Exo_\1:\4}

              But they will only work for examples like the ones you mentioned.
              If there is more than 2 sections in the line, it won't change the last one, so this one will fail:
              Ex 32:26-30; 34:31-34; 35:1, 4

              In that case, you will need a 2 step process, the one above, and another one to catch all the missed ones. The problem is that EditPlus does not have conditional replacements, so when the 3rd section in the line is optional, there is no way to tell EditPlus to replace it if its there and ignore it if its not -- particularly because we are replacing with strings that do not occur in the match. So you might end up with something like:
              {\cfll\ul Exo_\1:\2}\3 {\cfll\ul Exo_\1:\4}; {}
              which is not what you want.

              So, the second step should be:

              s: ({\cfll\ul Exo_([0-9]+):.+)([;,]) +([0-9:-]+)$
              r: \1\3 \2:\4

              But still, I need more information:
              What do the patterns mean and what are the combinations in which they will appear? Also, do you reall want to turn the last section of "Ex 2:1-4; 7:7" into "Exo_2:7:7"? I would imagine that it would be "Exo_7:7", no? Will there always be 2 or 3 sections on each line, or could there there be an infinite number of them? Are they by themselves in each line?

              dZ.

              Some time around 11/25/2004 13:22:36, I think I heard John Morse say:

              > Hello editplus,

              > I am in need of some help, I know I need mental help, but for now, i
              > just need help with a difficult reg expression search and replace.
              > I have many files that I need to search through and find all
              > occurances of (for example)
              > Ex 6:13, 16-20
              > Ex 2:1-4; 7:7

              > and change them to
              > {\cf11\ul Exo_6:13}, {\cf11\ul Exo_6:16-20}
              > {\cf11\ul Exo_2:1-4}; {\cf11\ul Exo_2:7:7}

              > I thought maybe If I could break them up into steps, like first
              > change all the instances like this (Ex 6:13, 16-20) to this
              > (Ex 6:13, Ex 6:16-20) notice how the verses are nested and needs to have the chapter
              > before it in every instance.

              > Then If I could figure out a reg ex that will change (Ex 6:13, Ex 6:16-20)
              > to (Exo_6:13, Exo_6:16-20)
              > Then I could finish up by using a reg ex that will look for either
              > Exo_6:13 or Exo_6:16-20 and wrap them with {\cf11\ul scripturehere}
              > like this {\cf11\ul Exo_6:16-20}

              > I know this is very difficult, and time consuming, but...
              > If anyone could help me with this i would be very appreciative. In
              > fact I will even send you a very old (but still usable) straight
              > razor from my personal collection! It will be honed and stropped by
              > me and will give you a good shave for a lifetime.

              > thanks in advance!
            • John Morse
              You are correct, I want Ex 2:1-4; 7:7 replaced with Exo_2:1-4; Exo_7:7 Attached is a macro that works in visual basic that matches all these, except, it leaves
              Message 6 of 7 , Nov 26, 2004
              • 0 Attachment
                You are correct, I want Ex 2:1-4; 7:7 replaced with Exo_2:1-4; Exo_7:7
                Attached is a macro that works in visual basic that matches all these,
                except, it leaves the scriptures nested out.
                These are nested scriptures, and each one has to have the book before
                it so that I can convert it to a e-sword file. What this search and
                replace will do is format the text so that each of these are a
                scripture tool tip and are linked in e-sword.

                Here is an example:

                As high priest, Aaron was responsible for directing all features of
                worship at the tabernacle and supervising the work of the thousands of
                Levites engaged in its service. (Nu 3:5-10) On the annual Day of
                Atonement he presented sin offerings for the priesthood and Levites
                and for the people of Israel, and he alone was permitted to enter the
                Most Holy of the tabernacle with the sacrificial blood of the animals.
                (Le 16) The daily offering up of incense, the presentation of the
                firstfruits of the grain harvest, and many other features of the
                worship were exclusive prerogatives of Aaron and his sons as priests.
                (Ex 30:7, 8; Lu 1:8-11; Le 23:4-11) His anointing, however, sanctified
                him to perform not only sacrificial duties for the nation but other
                duties as well. He was responsible to teach the nation the Word of
                God. (Le 10:8-11; De 24:8; Mal 2:7) He, as well as his successors,
                served as the chief officer under Jehovah the King. On high state
                occasions he wore the costly garments and the \ldblquote shining
                plate\rdblquote of gold on his linen turban. He also wore the
                breastpiece that contained the Urim and Thummim, enabling him to
                receive Jehovah\rquote s \ldblquote Yes\rdblquote or \ldblquote
                No\rdblquote to national problems; although, for the duration of
                Moses\rquote life and mediatorship, this feature appears to have
                received little use.-Ex 28:4, 29, 30, 36; see HIGH PRIEST.\par

                Here is an example of all the scriptures that need to be changed:
                1st one is the search, and the second one is what needs to be
                replaced.
                I figure i can modify the search and replace expression and run it
                with each of these.
                Ge
                Gen_
                Ex
                Exo_
                Le
                Lev_
                Nu
                Num_
                De
                Deu_
                Jos
                Jos_
                Jg
                Jdg_
                Ru
                Rth_
                1Sa
                1Sa_
                2Sa
                2Sa_
                1Ki
                1Ki_
                2Ki
                2Ki_
                1Ch
                1Ch_
                2Ch
                2Ch_
                Ezr
                Ezr_
                Ne
                Neh_
                Es
                Est_
                Job
                Job_
                Ps
                Psa_
                Pr
                Pro_
                Ec
                Ecc_
                Ca
                Son_
                Isa
                Isa_
                Jer
                Jer_
                La
                Lam_
                Eze
                Eze_
                Da
                Dan_
                Ho
                Hos_
                Joe
                Joe_
                Am
                Amo_
                Ob
                Oba_
                Jon
                Jon_
                Mic
                Mic_
                Na
                Nah_
                Hab
                Hab_
                Zep
                Zep_
                Hag
                Hag_
                Zec
                Zec_
                Mal
                Mal_
                Mt
                Mat_
                Mr
                Mar_
                Lu
                Luk_
                Ac
                Act_
                Ro
                Rom_
                1Co
                1Co_
                2Co
                2Co_
                Ga
                Gal_
                Eph
                Eph_
                Php
                Phi_
                Col
                Col_
                1Th
                1Th_
                2Th
                2Th_
                1Ti
                1Ti_
                2Ti
                2Ti_
                Tit
                Tit_
                Phm
                Phm_
                Heb
                Heb_
                Jas
                Jam_
                1Pe
                1Pe_
                2Pe
                2Pe_
                1Jo
                1Jo_
                2Jo
                2Jo_
                3Jo
                3Jo_
                Joh
                Joh_
                Jude
                Jud_
                Rev
                Rev_



                Friday, November 26, 2004, 5:04:35 AM, you wrote:
                DJ> But still, I need more information:
                DJ> What do the patterns mean and what are the combinations in
                DJ> which they will appear? Also, do you reall want to turn the
                DJ> last section of "Ex 2:1-4; 7:7" into "Exo_2:7:7"? I would
                DJ> imagine that it would be "Exo_7:7", no? Will there always be 2
                DJ> or 3 sections on each line, or could there there be an
                DJ> infinite number of them? Are they by themselves in each line?
              • DZ-Jay
                John, This makes it a lot easier to understand. Unfortunately, like I mentioned before, since the number of pages (or verses) on each entry is variable,
                Message 7 of 7 , Nov 26, 2004
                • 0 Attachment
                  John,
                  This makes it a lot easier to understand. Unfortunately, like I
                  mentioned before, since the number of pages (or verses) on each entry is
                  variable, EditPlus won't be able to change them all, unless you go
                  through a few regexp to try to get all the ones with, say, 5 pages (Ex
                  2: 1, 2, 3, 4, 5), all the ones with 4 pages (Ex 2: 1, 2, 3, 4), all the
                  ones with 3 pages, etc.

                  I personally suggest you use a more flexible medium, sort of like a
                  Perl script, which I can help you prepare. In Perl, it can be a very
                  simple and easy script.

                  dZ.

                  John Morse wrote:
                  > You are correct, I want Ex 2:1-4; 7:7 replaced with Exo_2:1-4; Exo_7:7
                  > Attached is a macro that works in visual basic that matches all these,
                  > except, it leaves the scriptures nested out.
                  > These are nested scriptures, and each one has to have the book before
                  > it so that I can convert it to a e-sword file. What this search and
                  > replace will do is format the text so that each of these are a
                  > scripture tool tip and are linked in e-sword.
                  >
                  > Here is an example:
                  >
                  > As high priest, Aaron was responsible for directing all features of
                  > worship at the tabernacle and supervising the work of the thousands of
                  > Levites engaged in its service. (Nu 3:5-10) On the annual Day of
                  > Atonement he presented sin offerings for the priesthood and Levites
                  > and for the people of Israel, and he alone was permitted to enter the
                  > Most Holy of the tabernacle with the sacrificial blood of the animals.
                  > (Le 16) The daily offering up of incense, the presentation of the
                  > firstfruits of the grain harvest, and many other features of the
                  > worship were exclusive prerogatives of Aaron and his sons as priests.
                  > (Ex 30:7, 8; Lu 1:8-11; Le 23:4-11) His anointing, however, sanctified
                  > him to perform not only sacrificial duties for the nation but other
                  > duties as well. He was responsible to teach the nation the Word of
                  > God. (Le 10:8-11; De 24:8; Mal 2:7) He, as well as his successors,
                  > served as the chief officer under Jehovah the King. On high state
                  > occasions he wore the costly garments and the \ldblquote shining
                  > plate\rdblquote of gold on his linen turban. He also wore the
                  > breastpiece that contained the Urim and Thummim, enabling him to
                  > receive Jehovah\rquote s \ldblquote Yes\rdblquote or \ldblquote
                  > No\rdblquote to national problems; although, for the duration of
                  > Moses\rquote life and mediatorship, this feature appears to have
                  > received little use.-Ex 28:4, 29, 30, 36; see HIGH PRIEST.\par
                  >
                  > Here is an example of all the scriptures that need to be changed:
                  > 1st one is the search, and the second one is what needs to be
                  > replaced.
                  > I figure i can modify the search and replace expression and run it
                  > with each of these.
                  > Ge
                  > Gen_
                  > Ex
                  > Exo_
                  > Le
                  > Lev_
                  > Nu
                  > Num_
                  > De
                  > Deu_
                  > Jos
                  > Jos_
                  > Jg
                  > Jdg_
                  > Ru
                  > Rth_
                  > 1Sa
                  > 1Sa_
                  > 2Sa
                  > 2Sa_
                  > 1Ki
                  > 1Ki_
                  > 2Ki
                  > 2Ki_
                  > 1Ch
                  > 1Ch_
                  > 2Ch
                  > 2Ch_
                  > Ezr
                  > Ezr_
                  > Ne
                  > Neh_
                  > Es
                  > Est_
                  > Job
                  > Job_
                  > Ps
                  > Psa_
                  > Pr
                  > Pro_
                  > Ec
                  > Ecc_
                  > Ca
                  > Son_
                  > Isa
                  > Isa_
                  > Jer
                  > Jer_
                  > La
                  > Lam_
                  > Eze
                  > Eze_
                  > Da
                  > Dan_
                  > Ho
                  > Hos_
                  > Joe
                  > Joe_
                  > Am
                  > Amo_
                  > Ob
                  > Oba_
                  > Jon
                  > Jon_
                  > Mic
                  > Mic_
                  > Na
                  > Nah_
                  > Hab
                  > Hab_
                  > Zep
                  > Zep_
                  > Hag
                  > Hag_
                  > Zec
                  > Zec_
                  > Mal
                  > Mal_
                  > Mt
                  > Mat_
                  > Mr
                  > Mar_
                  > Lu
                  > Luk_
                  > Ac
                  > Act_
                  > Ro
                  > Rom_
                  > 1Co
                  > 1Co_
                  > 2Co
                  > 2Co_
                  > Ga
                  > Gal_
                  > Eph
                  > Eph_
                  > Php
                  > Phi_
                  > Col
                  > Col_
                  > 1Th
                  > 1Th_
                  > 2Th
                  > 2Th_
                  > 1Ti
                  > 1Ti_
                  > 2Ti
                  > 2Ti_
                  > Tit
                  > Tit_
                  > Phm
                  > Phm_
                  > Heb
                  > Heb_
                  > Jas
                  > Jam_
                  > 1Pe
                  > 1Pe_
                  > 2Pe
                  > 2Pe_
                  > 1Jo
                  > 1Jo_
                  > 2Jo
                  > 2Jo_
                  > 3Jo
                  > 3Jo_
                  > Joh
                  > Joh_
                  > Jude
                  > Jud_
                  > Rev
                  > Rev_
                  >
                  >
                  >
                  > Friday, November 26, 2004, 5:04:35 AM, you wrote:
                  > DJ> But still, I need more information:
                  > DJ> What do the patterns mean and what are the combinations in
                  > DJ> which they will appear? Also, do you reall want to turn the
                  > DJ> last section of "Ex 2:1-4; 7:7" into "Exo_2:7:7"? I would
                  > DJ> imagine that it would be "Exo_7:7", no? Will there always be 2
                  > DJ> or 3 sections on each line, or could there there be an
                  > DJ> infinite number of them? Are they by themselves in each line?
                  >
                  >
                  > http://www.editplus.com
                  > http://groups.yahoo.com/group/editplus
                  > Yahoo! Groups Links
                  >
                  >
                  >
                  >



                  --
                  Bastard Operators don't just win. Anyone can win. Bastard Operators win
                  and totally demoralize. That's real winning.
                  - BOfH
                Your message has been successfully submitted and would be delivered to recipients shortly.