Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 03-22-2014, 07:36 AM   #1
asogn
Junior Member
asogn began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Feb 2011
Device: kindle
Search and replace substring

Hi

I am not very familiar with regex and now I have completely blackout....
Title is in following format:
xxxx xxxxx xxxxx (aa-##)
where x, a and # is in variable length
I would like to get the a's into a #Customfield1 (and also delete everything from ( in the title.
So in this case, the result should be
Title: xxxx xxxxx xxxxx
Customfield1: aa

There must be an easy way to do this, but I can't find it.
asogn is offline   Reply With Quote
Old 03-22-2014, 12:29 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,816
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
This appears to be a Add Books question which is Library management question. Moved there

I am not an expert in this area, so I will leave this to others for the code.

remember the custom fieldname stats with a # ( post the exact field lookup name if you want working code)

FYI anything not contained in a capture ( ) pair is dropped
theducks is online now   Reply With Quote
Advert
Old 03-22-2014, 02:58 PM   #3
Adoby
Handy Elephant
Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.
 
Adoby's Avatar
 
Posts: 1,736
Karma: 26785668
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
Device: Thinkpad E595, Ubuntu Mate, Huawei Mediapad 5, Bouye Likebook Plus
You have to do it in steps.

First get the contents inside () and before the - to #Customfield1:

Search title for: .*\((.*)-.*\)
Replace with: \1
Destination field: #Customfield1

This will put aa in #Customfield1.

Then remove the paranthesis:

Search title for: (.*)\(.*\)
Replace with: \1
Destination field: Title

Last edited by Adoby; 03-22-2014 at 03:02 PM.
Adoby is offline   Reply With Quote
Old 03-23-2014, 01:55 AM   #4
asogn
Junior Member
asogn began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Feb 2011
Device: kindle
Quote:
Originally Posted by Adoby View Post
You have to do it in steps.

First get the contents inside () and before the - to #Customfield1:

Search title for: .*\((.*)-.*\)
Replace with: \1
Destination field: #Customfield1

This will put aa in #Customfield1.

Then remove the paranthesis:

Search title for: (.*)\(.*\)
Replace with: \1
Destination field: Title
Thank you.
This works like a charm
asogn is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Replace Help Squidly21 Conversion 2 01-08-2014 12:19 AM
Need Help with Search and Replace please! worley Conversion 2 07-28-2012 09:29 AM
Search and Replace SOThunder Conversion 2 04-29-2012 08:29 AM
Search and replace TdeV Sigil 1 10-30-2011 04:45 PM
search and replace - drops blanks in replace ? cybmole Conversion 10 03-13-2011 03:07 AM


All times are GMT -4. The time now is 11:04 AM.


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