Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 05-01-2012, 10:02 PM   #1
Sidetrack
Enthusiast
Sidetrack began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Jan 2009
Location: South Pacific
Device: Kindle DX
Regex to selectively grab individual tags?

I've got some hierarchical tags that I'd like to "move" to a custom column so I can easily use them to make collections on my PRS-T1. There is a lot of this management that I want to to do so I'm hoping to use the Search&Replace dialog to do it.

I expected that something like "Accolade\.(.*)" in the regex field would let me extract the information I want but it seems to grab the rest of the tags as well. What am I missing to get from this:
{tags}
Places.Africa, Imperialism, Accolade.100 best.Radcliffe's, Accolade.100 best.Some Prize.1958, Accolade.100 best.Modern Library, Trading posts, Degeneration, People.Europeans

to this and this:
{#accolades}
100 best.Radcliffe's, 100 best.Modern Library Readers, 100 best.Modern Library, Trading posts

{tags}
Places.Africa, Imperialism, Trading posts, Degeneration, People.Europeans
Sidetrack is offline   Reply With Quote
Old 05-02-2012, 03:33 AM   #2
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,908
Karma: 1217216
Join Date: Jan 2010
Location: France
Device: Many android devices
When operating on columns such as "tags" that contain multiple items, the search/replace operation is applied to every item, item by item. The search is not a selector. Instead the text matched by the search regexp is replaced by the "replace" expression. Your expression says to modify only tags beginning with "Accolade.". All other tags are passed through unmodified.

The way to get what you want is to have the S/R modify every tag, removing some or all of the text. All text is removed if the tag does not begin with the desired word (e.g., "Accolade"), otherwise the desired word is removed leaving what follows. For example, the search expression
Code:
^((?!Accolade\.).*$)|(Accolade\.)
when used with a null replacement expression will remove the tag completely if it does not begin with "Accolade.", or remove the word "Accolade." leaving whatever follows. The expression
Code:
^Accolade\..*$
will remove all tags that begin with "Accolade.".
chaley is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help to compose a regex to find strings, enclosed in comments tags Vadim777 Conversion 5 04-17-2012 01:49 PM
Regex help needed, selecting single tags out of namy Sidetrack Library Management 5 02-26-2012 11:54 PM
Exporting based on individual tags BookJunkieLI Library Management 7 02-22-2012 05:18 PM
Amazon Tags - Popular tags vs Unique tags. chrisanthropic Writers' Corner 6 09-20-2011 12:18 AM
Google Allows Carriers to Selectively Block Tethering Apps From Android Market RockdaMan Android Devices 16 05-14-2011 08:19 PM


All times are GMT -4. The time now is 12:29 PM.


MobileRead.com is a privately owned, operated and funded community.