![]() |
#1 |
Enthusiast
![]() Posts: 39
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 |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
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\.) Code:
^Accolade\..*$ |
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
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 12:49 PM |
Regex help needed, selecting single tags out of namy | Sidetrack | Library Management | 5 | 02-26-2012 10:54 PM |
Exporting based on individual tags | BookJunkieLI | Library Management | 7 | 02-22-2012 04:18 PM |
Amazon Tags - Popular tags vs Unique tags. | chrisanthropic | Writers' Corner | 6 | 09-19-2011 11:18 PM |
Google Allows Carriers to Selectively Block Tethering Apps From Android Market | RockdaMan | Android Devices | 16 | 05-14-2011 07:19 PM |