11-08-2011, 05:54 AM | #1 |
Zealot
Posts: 115
Karma: 10
Join Date: Jan 2011
Device: none
|
Another Replace Question
The answer to Poppeye's question was very helpful for me too, thanks.
I would also be very grateful for help with another problem. Converting bad PDF files to MOBI I often need to replace garbage text with a space but I have no idea what to put in the replacement text window. I've tried \s; (\s); [\s], but neither works. What am I doing wrong? |
11-08-2011, 06:14 AM | #2 |
US Navy, Retired
Posts: 9,865
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
|
11-08-2011, 06:20 AM | #3 |
Zealot
Posts: 115
Karma: 10
Join Date: Jan 2011
Device: none
|
I have. does not work.
|
11-08-2011, 09:14 AM | #4 |
Wizard
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
I would think an actual space should have worked, you could try to wrap it in quotes to see if it helps.
An alternate way to specify it would be to use unicode notation, e.g. Code:
\u0020 |
11-08-2011, 10:59 AM | #5 |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
So would I. I often suspect (for pdf fixup problems) that the problem is not the failure to insert, it's that the "garbage text" in the pdf isn't getting matched so no insert will ever happen. To make sure, just replace it with some text, which is guaranteed to work, and see if your regex matching is actually working. What works in the wizard, does not always work when it runs, particularly if it's a multiline replace.
|
11-08-2011, 01:45 PM | #6 |
Zealot
Posts: 115
Karma: 10
Join Date: Jan 2011
Device: none
|
Thanks for all the answers.
The garbage text does get matched- it disappears. But if i try to use an actual space, no space is inserted. In other cases whatever was used for replacement was inserted as the actual text: \s; [\s]; (\s). |
11-08-2011, 02:36 PM | #7 |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Yes, \s is a whitespace regex matching element, not a space. It matches tabs, spaces and other types of whitespace, but doesn't actually define any particular character, so you don't want to use that in the replace field. The replace function wouldn't know which whitespace character to insert even if it was allowed. I've tested a search/replace operation during convert on my system and had no trouble replacing the searched regex with a single space.
|
11-08-2011, 02:54 PM | #8 |
Zealot
Posts: 115
Karma: 10
Join Date: Jan 2011
Device: none
|
Do you mean, you just press the space bar?
Don't know how it works for you, but i've just tried again & no space is inserted. |
11-08-2011, 03:18 PM | #9 |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
OOPs, sorry, I was too quick. I replaced the word "the" with a space and thought I was seeing multiple spaces, but either I wasn't, or I made some other error. Moreover, calibre won't hold the space as my replace text string if I leave that page or come back after conversion.
Even more interestingly, if I use space to replace "the", it doesn't leave double spaces (the original two that surrounded the original "the"). It only leaves one. |
11-09-2011, 02:04 AM | #10 |
Wizard
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
|
HTML rendering merges multiple spaces into a single space unless you make them an non-breaking space. If you want the space to be retained when there are multiple consecutive spaces then your replace code should use:
Code:
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
calibre search & replace question | Kelby | ePub | 1 | 09-29-2011 01:14 PM |
Search & Replace question - something not right | curiosity | Library Management | 21 | 06-15-2011 11:33 AM |
Search/Replace Question | seagull | Sigil | 22 | 03-21-2011 01:30 PM |
Simple edit/replace question from beginner | JustinD | Sigil | 6 | 03-20-2011 11:48 AM |
Question: find and replace with variables? | veezh | Recipes | 4 | 12-21-2010 05:23 AM |