wildcarding to code document

I am wanting to insert the milestone for verses using wildcard search and replaces. What I attempted was:
Search:
[0-9]{1,2,3}
Replace::
[[@Bible:Gênesis 4:\1]]\1
Thinking this would find any number composed of one, two or three digits, insert [[@Bible:Gênesis 4: , then the verse number(s), then repeat the verse number to be shown in the text.
however, this returned the error message "The Replace With text contains a group number which is out of range."
What am I doing incorrectly?
Is there a way to do this for more than a chapter at a time?
Thank you!
Mark
Comments
-
Mark A. Ellis said:
[0-9]{1,2,3}
You need to add the grouping operator to capture the text: surround what you want to capture with parenthesis. Each set of parenthesis will act as a capture group which you can then refer to.
([0-9]{1,2,3})
0 -
Thank you, Randy. I copied and pasted this string, and received the following error message:
"The Find What text contains a Pattern Match expression which is not valid"
I am so sorry. I stumbled upon the same pattern on the web, and have no idea why this is not working. If I try just (0-9) all works well. Word is choking on the request for two or three digit numbers.
I'll keep working on it from my end.
0 -
Sorry, my bad. I answered too quick trying to get to lunch. I wasn't paying close enough attention. The repetition operator {} takes either a single digit that represents an exact number of matches or two digits that represent a minimum and maximum. So it should be
([0-9]{1,3})
0 -
Do note that regexps can be extremely difficult to get right. This expression will grab anything that contains 1-3 numbers in it regardless of context. This will only work for the most simple cases. You might want to iterated over the matches to see if it is good enough for the document you are working on to make sure it doesn't match anything it shouldn't and that it matches everything you think it should. With a little more context we might be able to improve it a bit for you.
There are also many tutorials out there if you google "regex tutorial".
0