• Another Find & Replace Problem


    Greetings All-

    I had a similar problem a couple of years ago, and I must have lost the fix.  Or perhaps the language is just different enough where the old fix doesn’t work in this case. The first line below is the general format that exists for hyperlinks in about a dozen MS Word documents.  The 2nd two lines are functionally equivalent, as they both successfully load the specified location on the USCCB website.  I’d like to change each case of line 1 to either line 2 or line 3.  The first part I can manage; I can change:


    to: https://www.usccb.org/bible/  or to:  https://bible.usccb.org/bible/


    <span style=”color: #ff0000;”>http://www.usccb.org/nab/bible/matthew/matthew28.htm#v18  (OLD: DOESN’T WORK)</span>

    <span style=”color: #99ccff;”>https://www.usccb.org/bible/matthew/28:18  (NEW: WORKS)</span>

    <span style=”color: #99ccff;”>https://bible.usccb.org/bible/matthew/28?18  (NEW: WORKS)</span>


    Everything after the word bible/ is variable.   The find/replace strings needs to work, whatever the book title, chapter, or verse in the original hyperlink.  As always, many thanks for the advice.

    Casey H.

    Viewing 29 reply threads
    • #2556401


      1 user thanked author for this post.
    • #2556410

      Looking at a loaded page, the entire URL is lower case, but I don’t think this website cares.  The single chapter books are all called chapter 1.  If one types in 0 for a chapter, it takes you to an introduction for that book.


    • #2556529

      I’ve gotten this far:

      https://bible.usccb.org/bible/matthew28.htm&#8221; \l “v18”

      Everything is correct through bible/

      Now I need to put a / after the book title (matthew), retain the chapter number (28), delete everything between the end of the chapter number and the start of the verse number (18), and finally add a question mark before the verse number, making it look like this:


      The trick being to make it look like this for all book titles and chapter & verse numbers.


    • #2556565

      What did you do to delete the ‘first’ “matthew”, that is, change from
      [ … /matthew/matthew28. … ], to
      [ … /matthew28. … ]?

      And since your example is using just Matthew, have all the
      /book/bookchapter. references been changed to
      /bookchapter. ?

      It looks to me that you did ‘Changes C’ before you did ‘Changes B’.

      What am I misunderstanding?

    • #2556580

      I’m confused as to what keystrokes are needed to make the changes take place, so I started from scratch. I needed to write down the steps as well, because I’m trying to remember how I got rid of the back to back chapter names.  After the initial fix I think I changed org/bible/*/ to org/bible/

      I did a find .htm and replace with nothing to get rid of it.

      Trying to get rid of &#8221; \l “v is where I’m lost.


    • #2556590

      I think it would help to know what roll the quotes play.


    • #2556655

      “I think it would help to know what roll the quotes play.”
      What ‘quotes’ are you referring to?

      I don’t have Word so I don’t know what your Find/Replace panel looks like.
      Here, in Notepad and in WordPad, are examples of the Find/Replace entries for Changes B and Changes C.
      Changes B are one run (Replace All).
      Changes C will be once (Replace All) per book, possibly 66: Genesis … Revelation.


      1 user thanked author for this post.
    • #2556658

      This is a regex to do the whole lot in one go.



      The brackets break the matching into groups – 7 in total. The important bits are matching the numbers with \d and then using them in the replacement.
      $num is using the matching group number in the replace – in our case we use 1, 3, 5 and 7.

      cheers, Paul

      1 user thanked author for this post.
    • #2556866

      I pasted (.*\.org\/)(nab\/bible\/)(.*\/)(.\D*)(\d+)(\.htm#v)(\d+) into the search box and got no hits.

      I tried these two strings and am getting close:

      Find: .htm*v
      Replace: ?

      Find: http://www.usccb.org/nab/bible/*/
      Replace: https://bible.usccb.org/bible/

      This yields:


      I just need to figure out how to put the slash between the title and the chapter.



      • #2556896

        Hang tight / hold off, more directions coming.
        1 – The string provided by Paul T is for another powerful editing program (regex), not useful for where we are.
        2 – See coming reply to your next post.

        1 user thanked author for this post.
    • #2556877

      Another thought.  While it still looks like this:


      Is there a way to eliminate the 2nd matthew, given they are repetitive words, albeit with a / in between?  That would leave matthew/28.htm#v18.  I could clean out the junk from there.


      • #2556906

        I’m sorry, but you’ve lost me.
        Three posts up, you have
        – – – – –
        This yields:

        – – – – –
        but one post up, there is
        – – – – –
        While it still looks like this:

        – – – – –
        Which is it?
        Careful: Change A is [ .htm#v ] NOT [ .htm*v ].
        The first above here may show that ‘Change B’ works, which was a concern of mine.
        The second shows that ‘Change A’ and ‘Change C’ were not done.

        Let’s start over from an unchanged file. (A copy thereof, of course.)
        See 2556401 and 2556655
        Do Change A, then Change B, then Change C. In that sequence, please.
        And do only these changes, so that we can confirm the result after each stage.

        The format after each Change should be what is shown at 2556665.
        If the result after any change is not what is expected, stop and post back.

        1 user thanked author for this post.
    • #2556885

      I’m struggling with special characters.  I can use them to find a specific place, but they don’t seem to work for replacement.  E.g. If I use an * in the replace box, Word puts the * character into the document.  Do I need to add some other character in combination?


    • #2557022

      This is how the link looks before anything was accomplished.  That’s where thr tic tac toe symbol comes from.


      The two below are new efforts.  The * is a wild card that picks up everything between the .htm and the v.

      The latter f/r does the easy part, correcting http, nab, etc.  I’m just stuck with a final result that needs matthew28 (and all other chapter verses) to be matthew/28.

      Find: .htm*v
      Replace: ?

      Yields: http://www.usccb.org/nab/bible/matthew/matthew28.18

      Find: http://www.usccb.org/nab/bible/*/
      Replace: https://bible.usccb.org/bible/

      Yields: https://bible.usccb.org/bible/matthew28?18

      Which leaves just the need to insert / between matthew and 28


    • #2557028

      Success, gentlemen.  But it took 3 steps.  Perhaps there’s a way to smoosh the steps together.  The last sequence I copied from the help I received the last time I ran into a similar difficulty.  The final step put the / in the needed spot.  I still don’t understand quite how that works.  I think the search says to find a question mark between any two numbers (not sure what the @ does).  The replace inserted a / (presumably the first character), but I don’t get the \1? \2″

      Thank you both for the help.  You obviously spent considerable time on this for me.  It is very much appreciated.

      Warmest regards,


      1. Find: .htm*v
        Replace: ?
      2. Find: http://www.usccb.org/nab/bible/*/
        Replace: https://bible.usccb.org/bible/
      3. Find: ([0-9]@)?([0-9]@)”
        Replace: /\1?\2″
    • #2557149

      Step 3 is a regex statement.

      Find 2 elements separated by a question mark – brackets are the element statement.
      Each element is one or more digits.
      Replace with a forward slash, element 1, question mark, element 2.

      cheers, Paul

      1 user thanked author for this post.
    • #2557241

      Thanks Paul.  I’ve got the brunt of this saved, so hopefully the next time something changes just a bit, I’ll be able to figure out the key strokes.


    • #2557331

      Based on your posts I have put together a single find/replace for Word.

      Find: (*.org/)(nab/bible/)(*/)([a-z]@)([0-9]@)(.htm#v)([0-9]@)
      Replace: \1bible/\3\5?\7

      Can you test it for me?

      cheers, Paul

      1 user thanked author for this post.
    • #2557567

      Tried it twice.  Both times Word locked up with Find and Replace (Not Responding).

      My version is Office Professional Plus 2016.



    • #2557618

      Did you turn on wild card searches?
      You could test it using only Find.
      Try each segment and add as you go, e.g. (*.org/), then (*.org/)(nab/bible/) etc.

      cheers, Paul

    • #2557723

      I’ll try the pieces one at a time.  The first time through, I just clicked on replace all, the 2nd time, find next.  Crashed both times.  I’ll also check it on my laptop, which is Office 21 and WIN 11 vs Office 16 and WIN 10.


    • #2557731

      Independently, they all seem to find what they’re supposed to.  All together–another lock up.


    • #2557769

      Locks up on my laptop, too.


    • #2557871

      When you string them together one at a time?

      cheers, Paul

    • #2557964

      Aah!  I was lumping all seven entries together, from left to right.  So one at a time with  \1bible/\3\5?\7 in the replace box for each entry?

      I’m going to be out of town for a couple of days, so it will be a bit before I can get back to this.


    • #2558016

      Don’t replace, just a find for the test.

      cheers, Paul

    • #2559391

      They all seem to find more than what would be desired, in some cases inserting only a portion of a word before proceeding, then ending with a hyperlink.

      (*.org/)  find next finds:   and who was carried to the gate of the Temple daily to support himself by begging began in chapter 3. Peter healed the man and gave his second homily, proclaimed the resurrection of Christ and announcing to the Jewish crowd that by faith in the name of Jesus the man had been made strong and restored to health (Acts 3:16).

      (*.org/)(nab/bible/) finds: world, and I have chosen you out of the world, the world hates you.
      John 15:18-19

      (*.org/)(nab/bible/)(*/)  finds: cate, the Holy Spirit that the Father will send in my name “he will teach you everything and remind you of all that I told you.
      John 14:26


    • #2559648

      Thanks for the feedback. As I don’t have Word I can’t sort this out.  🙁

      cheers, Paul

      1 user thanked author for this post.
    • #2559853

      Quite all right.  You’ve helped me with a ton of stuff over the years.  I’m haapy that I have at least found a way to fix the links, even if I do have to make some separate entries.  Unfortunately the regex piece:

      Find: ([0-9]@)?([0-9]@)”
      Replace: /\1?\2″

      only works with Word and doesn’t work with my pdf software (ashampoo pdf pro 3), so I’m mostly out of luck with some old pdf files.  It’s not intolerable though, as the other elements take care of everything except the / between book and chapter.  When the unfound page loads, all I have to do is insert the / and the page then loads.  That’s still much quicker than opening the book and thumbing through the pages.  Thanks again, Paul.



      Just on a whim, I tried to make it work with Libre Writer.  I couldn’t find a “use wild cards” box and couldn’t change the hyperlink display. Alt+F8 didn’t do anything.

    • #2559902

      My first example works perfectly in LibreOffice Writer with a minor mod. Use Replace (Ctrl H) and tick the Regular expressions box.



      cheers, Paul

      1 user thanked author for this post.
    • #2560046

      I’ll give it a shot, first in Word, then in Libre.  If it only works in Libre, I can always fix the hyperlinks there, then return to Word after the repairs.


    • #2560080

      Tried in Word.  No longer freezes but makes no changes.  Can’t seem to make it work in Writer either: Clicking “Replace All,” returns, “Search Key Not Found.” I did tick the regular expressions box.

      It’s an interesting exercise, but I’m ready to put this one to bed.


    Viewing 29 reply threads
    Reply To: Another Find & Replace Problem

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: