![]() |
#1 |
Enthusiast
![]() Posts: 39
Karma: 10
Join Date: Jan 2009
Location: South Pacific
Device: Kindle DX
|
Regex help needed, selecting single tags out of namy
I'm having some trouble, I have a number of tags all prefixed with "QC: " that I'd like to extract from the tags column and dump into a custom tags column.
I can get at the tags I want just fine with (^QC[:] [^,]*) but I can't seem to come up regex to exclude the preceding and following tags so I can dump only the QC tags into the custom column. Any ideas? I'd really rather not apply them one at a time from the edit metadata interface. |
![]() |
![]() |
![]() |
#2 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,889
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Assume this is in Search and replace ![]() <not tested> Matches anything up to your term, your term, matches anything after your term (.*)your search term(.*) the replace into destination column: \2 |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,325
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Note that searching multiple fields like tags does a search tag by tag. If a search does not match, the value is not touched.
If you want to search tags (which will probably work best), then you must get fancy with the search expression so that it always matches the entire tag. Try Code:
^(QC[:] .*|).*?$ You can avoid the multiple-item processing by using "template" as the source field and "{tags}" as the template. In this case something like your expression would work, but you must not use the anchor to take care of the case where QT is not the first tag. In addition, it would probably be easier to remove the unwanted tags than to reconstruct the list of wanted tags. |
![]() |
![]() |
![]() |
#4 |
Enthusiast
![]() Posts: 39
Karma: 10
Join Date: Jan 2009
Location: South Pacific
Device: Kindle DX
|
Yes it is in Seach and Replace. That is the method I tried and it doesn't seem to work with multiple tags.
|
![]() |
![]() |
![]() |
#5 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,889
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Enthusiast
![]() Posts: 39
Karma: 10
Join Date: Jan 2009
Location: South Pacific
Device: Kindle DX
|
Using the {tags} template worked wonderfully. Removing tags will be no problem, if search and replace won't do the trick I don't mind removing them manually.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
restricting regex to single lines of code? | ElMiko | Sigil | 14 | 01-28-2012 04:39 PM |
Help with regex needed. | kamanza | Library Management | 3 | 01-24-2012 07:27 AM |
RegEx Help needed | ghostyjack | Sigil | 14 | 11-02-2011 10:22 AM |
Regex help needed | gandor62 | Calibre | 2 | 11-04-2009 10:27 AM |
Help needed in selecting a mobile reader | jdedecker | Which one should I buy? | 0 | 03-29-2009 08:59 AM |