Thread: Regex examples
View Single Post
Old 07-26-2019, 03:46 AM   #590
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Since Roman Numerals only use a handful of characters, I always just use something along these lines:

Search: \b([XIV]{2,})\b
Replace: <span class="romannumeral">\1</span>

That will find you most. (You can add LCDM if you want... but I've yet to see a book really go that high.)

Note #1: To get single character roman numerals, you'll have to be much more careful. I usually split it into different searches, because 'I' is such a common English word.

So something like this:

Search: \b([XV]+)\b

would find more single Roman Numerals.

Note #2: Roman Numerals usually also depend on some further context:
  • King Charles V ruled from [...]
  • See Chapter I.
  • The reference is on p. v.

so I use the specifics of the book to help refine the searches:

Search: Chapter ([XIV]+)
Replace: Chapter <span class="romannumeral">\1</span>

Last edited by Tex2002ans; 07-26-2019 at 03:53 AM.
Tex2002ans is offline   Reply With Quote