|
|
#1 |
|
Connoisseur
![]() Posts: 82
Karma: 10
Join Date: Jul 2023
Device: none
|
Odd regex problem
I wanted to change chapter numbers to title case, e.g. TWENTY to Twenty or TWENTY-THREE to Twenty-Three. I came up with these patterns
Find: Code:
([\p{Lu}])([\p{Lu}]+)((-)([\p{Lu}])([\p{Lu}]*))?
Code:
\1\L\2\4\5\L\6 Code:
\1|\L\2|\4|\5|\L\6 Code:
T|wenty|-|t|hree |
|
|
|
|
|
#2 |
|
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,034
Karma: 30277294
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
No idea from a technical perspective, but "Twenty-three" is the de-facto standard for Chapter numbers expressed in words - hyphenated sentence case.
BR |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,898
Karma: 207182180
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
You need to use an \E to terminate an \L or \U otherwise they'll just keep going. So I would suggest an \E immediately after the capture group that represents the '-' in the replace expression (or before it).
\1\L\2\E\4\5\L\6 Or: \1\L\2\4\E\5\L\6 I'm not at a computer where I can test the replace expression exactly. I also think you don't need the brackets [] around each individual \p{Lu} instance. Last edited by DiapDealer; 11-16-2023 at 10:29 PM. |
|
|
|
|
|
#4 | |
|
Connoisseur
![]() Posts: 82
Karma: 10
Join Date: Jul 2023
Device: none
|
Quote:
|
|
|
|
|
|
|
#5 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,898
Karma: 207182180
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
In our user guide? I doubt it. We only give the briefest of intros to regex. But I'm sure it's in any thorough documentation for the PCRE flavor of regex.
|
|
|
|
| Advert | |
|
|
|
|
#6 | |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 48,323
Karma: 174315444
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
|
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Odd link problem | Julanna | Conversion | 10 | 06-19-2014 04:19 AM |
| PRS-T1 Odd USB problem | TAG_Keri | Sony Reader | 12 | 07-16-2013 02:00 AM |
| Odd Problem | Pope Viper | Library Management | 3 | 06-23-2011 01:16 PM |
| Odd problem with Sigil 0.4 | bobcdy | Sigil | 7 | 06-23-2011 03:45 AM |
| Odd conversion problem | speakingtohe | Calibre | 2 | 05-10-2010 11:18 AM |