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 08-06-2020, 07:35 AM   #1
africalass
Connoisseur
africalass began at the beginning.
 
Posts: 54
Karma: 10
Join Date: Dec 2010
Location: Various - sometimes UK, sometimes South Africa, sometimes other countries in Europe / Africa
Device: Windows Laptop; Kindle Keyboard; Hudl2 (Android), iPhone
Help with regex for adding in a hyphen

Hi all!

I haven't used regex in some years, so I wondered if someone could possibly help with a simple expression? I'd be grateful if so, but no problem if not.

I would like to add in some punctuation - either a colon and space, or a space hyphen space, after the first word in the title. Then I want to do the same thing for other books but after the second word. I don't need to bring in anything from any other field, and I don't have any existing punctuation in any of the titles. I will select the books manually as to whether it's after the first / second words.

Thanks for any assistance.
africalass is offline   Reply With Quote
Old 08-06-2020, 08:48 AM   #2
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
The search for the first one would be:
Code:
(\w+)(.*)
The second would be:

Code:
(\w+ \w+)(.*)
With replacement:

Code:
\1 - \2
With whatever punctuation you want in there.

The above assumes the first word doesn't have a hyphen or apostrophe or some non-letter/number character.
davidfor is offline   Reply With Quote
Old 08-06-2020, 09:11 AM   #3
africalass
Connoisseur
africalass began at the beginning.
 
Posts: 54
Karma: 10
Join Date: Dec 2010
Location: Various - sometimes UK, sometimes South Africa, sometimes other countries in Europe / Africa
Device: Windows Laptop; Kindle Keyboard; Hudl2 (Android), iPhone
Thanks so very much for your time.
I'll have a go now 👍
africalass is offline   Reply With Quote
Reply

Tags
reg expressions, regex


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding books, need regex help sealbeater Library Management 2 07-30-2018 02:00 AM
[iOS] Adding Books to Hyphen reader tdanzie Calibre Companion 4 01-18-2017 10:32 AM
Adding with Regex thepauler Library Management 2 08-31-2014 02:25 PM
Adding books - regex help tonyx3 Library Management 1 03-13-2013 08:21 AM
A little help adding books and using regex. Dragonator Calibre 7 12-17-2010 06:57 PM


All times are GMT -4. The time now is 09:58 AM.


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