![]() |
#1 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Jun 2018
Device: Android Phone, Samsung Galaxy Note 5, Moon + Reader Pro
|
RegEx question: Phrases starting with a small letter only
Hi
I am new to RegEx, but I want to use 'Tag mapper' and RegEx to put my tags in order (I imagine you are already cursing me ![]() I want to capitalize all the tags that begin with a small letter. My ideal conversion is "this test" -> "This Test" but I think it cannot be. So, "this test" to "This test" will also do. I tried this: Tage mapper > Capitalize the tag, if it matches pattern: Code:
^[a-z].+?$ Code:
this test Code:
John Milton Code:
John milton It seems I'm doing something wrong. Your help would be appreciated. ![]() |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,210
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
iirc the regex is treated as case-insensitive which is why a-z matches upper case letters as well.
|
![]() |
![]() |
![]() |
#3 | ||
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Jun 2018
Device: Android Phone, Samsung Galaxy Note 5, Moon + Reader Pro
|
Quote:
Example: https://www.rexegg.com/regex-modifiers.html I searched StackOverflow but all of the questions were about how to make RegEx case-insensitive. Perhaps the RegEx engine that Calibre uses is case-insensitive? But if so, is there a way to make it case-sensitive? === EDIT === This text has been quoted from the link above: Quote:
Last edited by BlackCanopus; 12-21-2018 at 05:11 AM. |
||
![]() |
![]() |
![]() |
#4 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,638
Karma: 29710510
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Elsewhere in calibre Title Case ups first char in each word, Capitalise only ups the first char in first word.
FX right click Series Name cell, select Change Case->Title Case will change dog's breakfast to Dog's Breakfast whereas Change Case->Capitalise will change it to Dog's breakfast. Seems a bit odd the Tag Mapper does not offer Titlecase. BR |
![]() |
![]() |
![]() |
#5 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,210
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
It is case-insensitive deliberately, i/e/ the ignore case flag is passed by default. You can turn it off IIRC by prefixing with a minus, something like this:
(?-i:...) see https://pypi.python.org/pypi/regex |
![]() |
![]() |
![]() |
#6 | ||
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Jun 2018
Device: Android Phone, Samsung Galaxy Note 5, Moon + Reader Pro
|
Quote:
Quote:
![]() |
||
![]() |
![]() |
![]() |
#7 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,210
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I dont really see the point, tags are not titles, so why would title case be appropriate for them? You want to turn off case insensitivity, do it like I showed you
Code:
(?-i:^[a-z].+?$) |
![]() |
![]() |
![]() |
#8 | |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Jun 2018
Device: Android Phone, Samsung Galaxy Note 5, Moon + Reader Pro
|
Quote:
As for the reason (for those who may be interested), titles such as John Milton, James Joyce, etc. may be used as tags. Note that these are not author names, but tags for books about those authors. This is used in literary criticism, I can imagine many other scenarios that use titles as tags. For example: Code:
Title: Novel Destinations, 2nd Edition Authors: Shannon McKenna Schmidt & Joni Rendon Tags: Charlotte Bronte, Emily Bronte, Ernest Hemingway, Fiction, Jack Kerouac, James Joyce, Jane Austen, Kafka, Literary Criticism & Collections, Literary Studies, Louisa May Alcott, Mark Twain, Novel, Virginia Woolf Published: May 2017 Publisher: National Geographic Society |
|
![]() |
![]() |
![]() |
#9 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,914
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
some folk only use lowercase, others the hated (shouting) Uppercase there will always be the rule busters: LITRPG, SF... that need TLC |
|
![]() |
![]() |
![]() |
#10 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,638
Karma: 29710510
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Another case for using titlecase on Tags is place names - New York, West Australia, Tunbridge Wells etc. Novels are often just as much about places as they are about people.
BR |
![]() |
![]() |
![]() |
Tags |
regex, tag mapper |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
regex capitalize first letter | larysa | Editor | 8 | 10-23-2017 12:04 PM |
Shortcut for Jumping to Author (starting letter)? | trumphodge | Library Management | 3 | 04-01-2016 12:30 PM |
Regex to find small letter followed by capital? | Vortex | Library Management | 2 | 03-18-2016 06:16 AM |
Search for first author_sort entry starting with letter x | StillReading | Calibre | 3 | 10-13-2015 02:45 AM |
another regex puzzle - detect capitalised phrases | cybmole | Sigil | 6 | 02-24-2012 09:04 AM |