#1
|
|||
|
|||
Regular expression confusion!
Hi,
My brain is about to overheat, as I've been trying to get a regular expression to do the following job. I've been sent a document consisting of a biblical treatise. The author has asked me to mark all biblical references for indexing. They are in the following format where 9 equals numeric and X equals alphanumeric: Xx. 99:99 9Xx. 99:99 Xx. 99:99-99 Using the find command, I can get the chapter and verse working, i.e. [0-9]{1,2}:[0-9]{1,2} But including the book, i.e. [A-z][0-9]{1,3}. [0-9]{1,2}:[0-9]{1,2} produces no results. To throw another spanner in the works, adding a -99 is optional, i.e. most don't but some do. If anyone can come up with a way to include them all, I'd be extremely grateful. It may be that I end up having to find the chapter and vers, then extend the selection somehow, Thanks, |
#2
|
||||
|
||||
Instead of reinventing the wheel, see: https://www.msofficeforums.com/word-...ure-index.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Paul, Just the kind of answer I like. I'll read through this, and see how I get on,
Best, David. |
#4
|
|||
|
|||
Hmm, interesting but...
Quote:
Thanks, David. |
#5
|
||||
|
||||
Quote:
Find = <[0-9A-Z]{1,2}[a-z.]{2,5} [0-9]{1,}:[!^s .,;”\)]{1,} Note: the 5 in {2,5} assumes longer names are abbreviated. No. In StrBks, for example, they're used to delineate where | characters in the string are to be replaced by non-breaking spaces, which the board software doesn't support. This is explained in the preamble. In the calls to MakeDupes & HideDupes, they're used to delineate where | characters in the string are to be replaced by either a comma or semi-colon, depending on the user's regional settings.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
Very many thanks
Aaargh! My dream of becoming a Word MVP moves ever further away. Impressed
|
#7
|
|||
|
|||
Quote:
Be careful what you wish for! |
#8
|
|||
|
|||
still an issue
Paul, Yes, this wheel you've invented is pretty good, but I'm using a slightly different vehicle. I don't normally mention this in the context of a forum, but I've no sight, and use a screen reader. Whilst I would like to get out of writing anything, the request from my friend is pretty specific. He wants all entries marked, then wants to create the index himself. The pattern you've recommended works fine, but I misled you (screen reader again). the books actually have a space between number and book, i.e. 1 Pe. Not to be defeated, I tried putting a \s into your pattern, but it found no results. on googling tutorials, I've found some rather patchy results. I am very happy to invent this particular wheel, and before reviving this thread, made every effort to find a solution.
Thanks, David |
#9
|
||||
|
||||
In that case, as advised at the top of the post in the link, the spaces between the numbers and book names can be corrected:
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
|||
|
|||
Paul,
Many thanks. I'll certainly give it a spin now, Best, David. |
#11
|
|||
|
|||
Hi Paul,
Yes, getting into this now. Purely a question as to the mechanics of the regex. 1.What does the < sign signify at the beginning of a regex. 2.What does the | signify? Thanks, David. |
#12
|
||||
|
||||
The < and > characters specify that whatever follows or precedes, respectively, must represent the start or end of a string, rather than simply occurring somewhere within another string. Note that we're discussing Word wildcards here, not RegEx, per se. for more on Word wildcards, see: Finding and replacing characters using wildcards
I answered your question about | in post #5.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
bible reference, regular expression, vba |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Is it possible to use wild cards or regular expression in autocorrect | kcvinu | Word | 2 | 12-14-2018 02:06 PM |
Regular Expression Syntax to Search for Alternative Words | qubie | Word | 2 | 11-29-2017 05:48 AM |
VBA code to enable Regular Expression | ronmayerle | Word VBA | 2 | 11-20-2014 01:09 PM |
Microsoft Expression Web | ts6947 | Misc | 0 | 02-22-2013 08:20 AM |
Can pass .expression as a parameter? | tinfanide | PowerPoint | 4 | 12-28-2012 06:14 PM |