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

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 11-22-2017, 07:25 AM   #1
reinsley
Enthusiast
reinsley began at the beginning.
 
reinsley's Avatar
 
Posts: 40
Karma: 10
Join Date: Dec 2016
Location: France
Device: Kindle PaperWhite
Search colon mark without space

Hi,

In the Calibre editor, I am looking for a kind of conditionnal "search and replace". The first step is a search only about the colon ( : ) punctuation mark.

Some texts are not correct.
For example "word: word".
It should be "word : word".
To say it another way the colon should have a space on each side. "wordspace:spaceword"

How can I search for "anyword:" ( a word without space and colon) into the text part only ? If I can avoid the HTML tags and markers...

I saw a tricky method following Python rules but it's out of my competence field.
I'd like to do it with the main GUI's Search and Replace boxes.

TIA for your help.

Best regards
reinsley is offline   Reply With Quote
Old 11-22-2017, 11:21 AM   #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: 24,771
Karma: 34257999
Join Date: Aug 2009
Location: The Central Coast of California
Device: K4NT(Fixed,New Bat.), Galaxy Tab A, Kobo Aura2
Quote:
Originally Posted by reinsley View Post
Hi,

In the Calibre editor, I am looking for a kind of conditionnal "search and replace". The first step is a search only about the colon ( : ) punctuation mark.

Some texts are not correct.
For example "word: word".
It should be "word : word".
To say it another way the colon should have a space on each side. "wordspace:spaceword"

How can I search for "anyword:" ( a word without space and colon) into the text part only ? If I can avoid the HTML tags and markers...

I saw a tricky method following Python rules but it's out of my competence field.
I'd like to do it with the main GUI's Search and Replace boxes.

TIA for your help.

Best regards
I think this will work in general (will find stuff outside the <body> so no Replace All reccomended

Code:
\>.+?\w\:\w
theducks is offline   Reply With Quote
Advert
Old 11-22-2017, 02:08 PM   #3
BetterRed
null operator
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 15,721
Karma: 18415750
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Moderator Notice
Moved to Editor sub-forum


@reinsley - if you separate the colon from the preceding word with a regular space, then when the text is flowed the colon could end up at the beginning of a line, which can look a bit odd. You could use a non-breaking-space to prevent that happening, but that opens up another can of worms.

BR

Last edited by BetterRed; 11-22-2017 at 02:12 PM.
BetterRed is offline   Reply With Quote
Old 11-22-2017, 03:06 PM   #4
reinsley
Enthusiast
reinsley began at the beginning.
 
reinsley's Avatar
 
Posts: 40
Karma: 10
Join Date: Dec 2016
Location: France
Device: Kindle PaperWhite
@the ducks

Thank you for your help.

I wrote \>.+?\w\:\w into the search box. And hit the search button.
Mode normal. All the text files. Calibre 3.12 x64.

I got Error : not found
You have desactivated the total search, all the text was not search for.
Start again the search and allow the 'together' box ( in the lower part of the search windows).

I have no together box (if it's a good translation). Where can I find this option ?

Nota : I translate the warning/error message, I hope it may help.

TIA. Best regards.

@BetterRed

Sorry for the mess, Editor section was the good one.

I discover the non-breaking-space that solve this issue and save me a lot of time for the next step.

In french language it's rather simple, all the double mark is spacemarkspace such as ; ! ? :
A simple mark as dot is worddotspacenewword same for comma parenthesis etc.

The eye is attacked when it detects that there is no space before and after double punctuation.
It's about comfort.

Thank you. Best regards.
reinsley is offline   Reply With Quote
Old 11-22-2017, 03:24 PM   #5
deback
Book E d i t o r
deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.
 
Posts: 370
Karma: 110636
Join Date: May 2015
Device: Laptop
Change Normal mode to Regex mode and try it again.
deback is offline   Reply With Quote
Advert
Old 11-22-2017, 04:54 PM   #6
BetterRed
null operator
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 15,721
Karma: 18415750
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by reinsley View Post
@BetterRed

Sorry for the mess, Editor section was the good one.

I discover the non-breaking-space that solve this issue and save me a lot of time for the next step.

In french language it's rather simple, all the double mark is spacemarkspace such as ; ! ? :
A simple mark as dot is worddotspacenewword same for comma parenthesis etc.

The eye is attacked when it detects that there is no space before and after double punctuation.
It's about comfort.

Thank you. Best regards.
Not as simple as English though

Had I known you were French I would have understood why you wanted a space. Suggestion - put your country in User CP (Control Panel)->Edit your Details.

BR
BetterRed is offline   Reply With Quote
Old 11-22-2017, 05:48 PM   #7
deback
Book E d i t o r
deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.
 
Posts: 370
Karma: 110636
Join Date: May 2015
Device: Laptop
I would search for it this way, using Regex and Case Sensitive checked:

([a-z])([:]) ([a-z])

Replace with the following:

\1 \2 \3

If any of the two letters could be capitalized, then I would use this:

([a-zA-Z])([:]) ([a-zA-Z])

and replace with the same string listed above.
deback is offline   Reply With Quote
Old 11-23-2017, 07:16 AM   #8
reinsley
Enthusiast
reinsley began at the beginning.
 
reinsley's Avatar
 
Posts: 40
Karma: 10
Join Date: Dec 2016
Location: France
Device: Kindle PaperWhite
A little recap :

1 - \>.+?\w\:\w does not work whatever the params. ( regex, caps ON...)

2 - ([a-z])([:]) ([a-z]) does not work

3 - ([a-zA-Z])([:]) ([a-zA-Z]) is the solution.
It works like a cuckoo clock.
The space avoids the HTML tags, noble text only search. It's perfect.

I did not use the auto replace, next time. I did it manually. The job was done easily.

NB : Most of the time the result is center page and yellow underlined.
Three or four times, the yellow line was out of the visible part. Just few page up were needed to find the occurence and to see the yellow line.
Could be a slight inconsistency with this advandced search.

Thank you Gents, special mention to deback.
Best regards.
reinsley is offline   Reply With Quote
Old 11-23-2017, 10:08 AM   #9
deback
Book E d i t o r
deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.deback figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.
 
Posts: 370
Karma: 110636
Join Date: May 2015
Device: Laptop
#2 worked for me, but it will only work when the letter on each side of the colon is smallcase (The Case Sensitive box must be checked for this to work properly), so I agree that #3 is the better choice. You can also use [\w] instead of [a-zA-Z] to search for any letters and numbers on each side of the colon. Including the surrounding parentheses allows you to replace and can be omitted when you will replace manually.
deback is offline   Reply With Quote
Old 11-24-2017, 06:39 AM   #10
reinsley
Enthusiast
reinsley began at the beginning.
 
reinsley's Avatar
 
Posts: 40
Karma: 10
Join Date: Dec 2016
Location: France
Device: Kindle PaperWhite
([\w])([:]) ([\w]) is a killing search too.
To run in #2 pass after ([a-zA-Z])([:]) ([a-zA-Z])

Great.

Your last sentence is not clear for me.
Quote:
Including the surrounding parentheses allows you to replace and can be omitted when you will replace manually.
reinsley is offline   Reply With Quote
Old 11-30-2017, 12:46 PM   #11
Nicolas F
Groupie
Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.Nicolas F once ate a cherry pie in a record 7 seconds.
 
Posts: 152
Karma: 1842
Join Date: Jan 2016
Device: Kobo Glo HD
Quote:
Originally Posted by reinsley View Post
([\w])([:]) ([\w]) is a killing search too.
To run in #2 pass after ([a-zA-Z])([:]) ([a-zA-Z])

Great.

Your last sentence is not clear for me.
You could also use the search
Code:
(>[^<>]*[^\s]):
and replace with
\1 :
This will find every instance where ":" follows a character that is not a space. This way you also match ":" that follows a parenthesis.

Vous pouvez utiliser l'expression ci-dessus. De cette manière vous pourrez trouver également les deux points qui pourraient être collés à une parenthèse fermante. L'expression veut dire chercher le caractère > puis n'importe quel nombre de caractères qui ne sont pas < ou > puis n'importe quel caractère qui n'est pas un espace (ou un retour à la ligne, espace insécable etc.) puis le caractère :
Nicolas F is offline   Reply With Quote
Old 12-01-2017, 05:54 AM   #12
reinsley
Enthusiast
reinsley began at the beginning.
 
reinsley's Avatar
 
Posts: 40
Karma: 10
Join Date: Dec 2016
Location: France
Device: Kindle PaperWhite
@Nicolas F

Thank you, works fine, in one shoot, Regex mode.

The ultimate in search-replace.

C'est exactement ce que je cherchais.

Best Regards.
reinsley is offline   Reply With Quote
Old 02-11-2020, 12:13 PM   #13
Pachuqismo
Member
Pachuqismo began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Nov 2009
Device: SM-T820, Galaxy S7
@ Nicolas F

Hi there,

This is an old thread so I hope somebody will pick this up. In the titles I've tried to replace '*:' with '* :' but I'm doing something wrong.

To ensure that I'm not adding a duplicate book to my collection, I use Everything to search in my files for the new title I consider adding. It's pretty much instant and doesn't require Calibre but titles which may have a colon attached to the main title, in Windows has to be represented by '*_' and will not show in the search results. Consequently, in Calibre I need to replace: 'title: subtitle' with 'title : subtitle'.

In latest Calibre I'm using the Edit meta information with Search and replace selecting: Search and Destination fields as title. Other parameters are Regular expression and the Mode as Replace field.

As per your instructions, the Search for I have as \>.+?\w\:\w and the Replace with as \1 :, however it doesn't work...

Any guidance as to what I'm doing wrong?

Cheers!

Last edited by Pachuqismo; 02-11-2020 at 12:15 PM. Reason: Clarification
Pachuqismo is offline   Reply With Quote
Old 02-11-2020, 04:50 PM   #14
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: 24,771
Karma: 34257999
Join Date: Aug 2009
Location: The Central Coast of California
Device: K4NT(Fixed,New Bat.), Galaxy Tab A, Kobo Aura2
The slash1 (\1) requires a capture in the search

(\w):

Whatever (a word, in this case) was inside the () will be used
theducks is offline   Reply With Quote
Old 02-12-2020, 10:23 AM   #15
Pachuqismo
Member
Pachuqismo began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Nov 2009
Device: SM-T820, Galaxy S7
Quote:
Originally Posted by theducks View Post
The slash1 (\1) requires a capture in the search

(\w):

Whatever (a word, in this case) was inside the () will be used
Thanks for your response. I wasn't being very clear (used the wrong expression). Better I show you what I fill out with five book examples four of which have Title:Subtitle which I would like to change to: Title : Subtitle
Attached Thumbnails
Click image for larger version

Name:	Edit_meta_information_2020-02-12_09;17;22.png
Views:	23
Size:	145.1 KB
ID:	177097  
Pachuqismo 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
bookerly font - space after speech mark for C, K stumped Amazon Kindle 7 05-08-2016 11:57 AM
Help with RegEx to parse title with colon racergirl76 Library Management 3 02-16-2016 02:13 AM
EPUB to MOBI, kindle shows extra space after quotation mark akita Kindle Formats 29 02-05-2016 02:14 AM
Hard Sci-Fi Space Opera- HEGEMONY, by Mark Kalina markkalina Self-Promotions by Authors and Publishers 54 09-04-2012 10:01 AM
search replace puts \1(space) in text isabelle1231 Sigil 2 05-21-2011 04:46 PM


All times are GMT -4. The time now is 05:06 AM.


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