01-09-2021, 04:35 AM | #1 |
Fanatic
Posts: 500
Karma: 3498633
Join Date: May 2011
Location: Surrey, UK
Device: Kobo Aura One, Sony PRS 600/650
|
Search and Replace
I am having a few issues with search and replace that I can't seem to find an answer to.
How do I make S&R case sensitive? How do I make S&R find and replace whole words only? I have done a number of S&Rs on a whole book and have found that it appears to not only replace words with the same case but those of the opposite case too - i.e. a search for color to replace with colour will also replace Color with colour. Another issue I have come across is that if the search term I am looking for - as a whole word - is embedded in another word that appears to get changed too. I have looked in preferences and can't seem to see anything that relates to this. |
01-09-2021, 07:17 AM | #2 |
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
After you press Ctrl+F, you should be able to change Mode to "Case Sensitive".
If you change Mode to "Regex", you can use Regular Expressions. In Regular Expressions, \b = a word boundary... so if you wanted to search for a whole word: Search: \bcolor\b Replace: colour Note: Regular Expressions are already case sensitive, so that won't match "Color" or "Colors". And since it's whole words, it won't match "colorimeter" or "technicolor". Alternate Method Your best bet will probably be Sigil's fantastic Tools > Spellcheck > Spellcheck. This allows you to search through all words in a book in an easy-to-read list. In there, you're also able to select a word, then "Change Selected Word to": Last edited by Tex2002ans; 01-09-2021 at 07:21 AM. |
Advert | |
|
01-09-2021, 07:50 AM | #3 |
Fanatic
Posts: 500
Karma: 3498633
Join Date: May 2011
Location: Surrey, UK
Device: Kobo Aura One, Sony PRS 600/650
|
Thanks Tex2002ans - that seems to be just what I was looking for.
|
01-09-2021, 08:27 AM | #4 |
Fanatic
Posts: 500
Karma: 3498633
Join Date: May 2011
Location: Surrey, UK
Device: Kobo Aura One, Sony PRS 600/650
|
I have tried the Spellcheck option as suggested by Tex2002ans and I get the following result -
https://www.mobileread.com/forums/at...1&d=1610198353 The language has defaulted to US English (the book was published in the US) so it is now picking up words that I have already corrected to UK spelling as being misspelled. I have tried clicking on the Language column to see if I can change it to UK English so that it spellchecks against the default UK dictionary, but there appears to no way to do that. What am I missing? |
01-09-2021, 08:47 AM | #5 |
Guru
Posts: 771
Karma: 2297170
Join Date: Jan 2017
Location: Poland
Device: Various
|
How is Sigil to know a word is in British and not American?
If the main language is set to US, individual phrases in British must be clearly marked: Code:
<span xml:lang="en-GB">colour</span> |
Advert | |
|
01-09-2021, 09:16 AM | #6 |
Fanatic
Posts: 500
Karma: 3498633
Join Date: May 2011
Location: Surrey, UK
Device: Kobo Aura One, Sony PRS 600/650
|
Sorry Becky, I'm not sure I understand you.
The book was written with US spellings and all I want to do is spellcheck it against the default UK dictionary. The spellcheck pop-up has spotted that it's a US book -as the language column has been set to that - so it's telling me that UK spellings are wrong. All it appears to be doing at the moment is highlight words that it considers are misspelt in American and NOT those that are misspelt in UK English because it's checking against a US dictionary - which I don't have set as my default. Oh, and the language in the opf is - <dc:language>en</dc:language> Last edited by Ashjuk; 01-09-2021 at 09:18 AM. |
01-09-2021, 10:30 AM | #7 |
Sigil Developer
Posts: 8,109
Karma: 5450184
Join Date: Nov 2009
Device: many
|
In Sigil Preferences: set your Primary Spellcheck dictionary to English-Great Britain.
Then try spellchecking again. If there are still issues, then look for lang or xml:lang attributes set to en-US someplace in the html. |
01-09-2021, 10:50 AM | #8 |
Fanatic
Posts: 500
Karma: 3498633
Join Date: May 2011
Location: Surrey, UK
Device: Kobo Aura One, Sony PRS 600/650
|
Thanks Kevin,
My default dictionary was already set to English - Great Britain, but your second suggestion was the problem as the headers all had lang="en-US" xml:lang="en-US in them. I have removed the -US from them and Spellcheck now works as it should and only picks up UK misspelled words. I will remember to look for that in the future. |
02-25-2021, 03:39 AM | #9 |
Connoisseur
Posts: 60
Karma: 201178
Join Date: Mar 2015
Location: Israel
Device: Kobo Aura H20, Kobo Forma
|
|
02-25-2021, 04:47 AM | #10 |
Guru
Posts: 771
Karma: 2297170
Join Date: Jan 2017
Location: Poland
Device: Various
|
Although it does not make sense, entering both will not hurt, and may help the disabled. It is important to correctly declare the correct language. Why? Well, the disabled use various software to read the text. The software is different – one program recognizes "lang", the next "xml:lang", and another recognizes both.
So typing both IMHO is not a bad idea. But I know that there are people here who have the opposite opinion. http://kb.daisy.org/publishing/docs/html/lang.html |
02-25-2021, 11:17 AM | #11 | |||
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
Quote:
If you only have one set, you can add the other using regex. 1. If you only have lang: Code:
<span lang="en-GB">colour</span> Replace: <span lang="\1" xml:lang="\1"> 2. If you only have xml:lang: Code:
<span xml:lang="en-GB">colour</span> Replace: <span lang="\1" xml:lang="\1"> Both will give you: Code:
<span lang="en-GB" xml:lang="en-GB">colour</span> In your case, it would probably be better to mark the entire book + each chapter as "en" (English). This would handle both American + British spellings, and then you can set your dictionary to handle which red squigglies you want to see. (Obviously, you'd go with the superior American dictionary/spellings!!! ) Related Side Note: And IF you're going around marking all "foreign words" within a book, back in 2019 I wrote: "Is there a way to use the selection in a Saved Search?" (Post #29) All you'd have to do is change my <i> into <span>. The instructions were for Calibre, but the same exact steps should apply in Sigil too. Quote:
lang = HTML xml:lang = XML Most tools I've seen handle both, but there could be tools that only parse one or the other. (For example, a purely XML program might only understand xml:lang.) Last edited by Tex2002ans; 02-25-2021 at 11:33 AM. |
|||
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Search and Replace | Rellwood | Library Management | 2 | 06-21-2018 07:53 PM |
Regex in search problems (NOT Search&Replace; the search bar) | lairdb | Calibre | 3 | 03-15-2017 07:10 PM |
save multiple search/replace, or search/replace multiple ebooks | user743 | Editor | 12 | 04-12-2014 02:38 AM |
search and replace - drops blanks in replace ? | cybmole | Conversion | 10 | 03-13-2011 03:07 AM |
Search and replace in 0.2.0 | paulpeer | Sigil | 7 | 03-13-2010 11:59 AM |