12-12-2018, 08:03 PM | #1 |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
How to remove blank spaces in a word with RegEx?
Hi friends:
I have something like: Code:
<h1 title="My Title">C H A P T E R 1</h1> Code:
<h1 title="My Title">CHAPTER 1</h1> TIA Rubén |
12-13-2018, 06:19 AM | #2 |
Banned
Posts: 168
Karma: 10010
Join Date: Oct 2018
Device: Tolino/PRS 650/Tablet
|
Depends. It can be impossible or very easy. If its always the word CHAPTER, tats easy, and i guess you woudn't have asked
If all letters are capital you can just search for ([A-Z])_ and reaplce it with \1. The probality that a capital letter is followed by a blank is low, but not 0. So yo have to go through the text one at a time to make a decision. In any other case i would assume its not possible as Regex in sigil cant be limited to work only inside a specific element (AFAIR Calibre can do that) So you are catching too many wrong positives if your heading is mixed-case. |
12-13-2018, 10:09 AM | #3 |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Simply add that element to the reflex pattern if you only want to search inside a specific tag element
|
12-13-2018, 10:39 AM | #4 | |||
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Quote:
Quote:
Last edited by RbnJrg; 06-06-2021 at 03:22 PM. |
|||
12-13-2018, 10:40 AM | #5 |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
|
12-13-2018, 11:27 AM | #6 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
@RbnJrg,
This is stretching my limited regex lookahead knowledge The closest I could get (tested in calibre) was something like: Code:
Find:\b([a-z])\s+(?=(\w\s+\w)) Replace:\1 I think you'd need to replace them one-by-one not 'Replace All'. Last edited by jackie_w; 12-13-2018 at 11:39 AM. |
12-13-2018, 11:32 AM | #7 | |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
|
|
12-13-2018, 02:19 PM | #8 | |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Code:
C H A P T E R V I I I Code:
CHAPTERVII I |
|
12-13-2018, 02:21 PM | #9 | |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
|
|
12-13-2018, 05:09 PM | #10 |
mostly an observer
Posts: 1,515
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
|
12-17-2018, 02:54 AM | #11 |
Banned
Posts: 168
Karma: 10010
Join Date: Oct 2018
Device: Tolino/PRS 650/Tablet
|
By the was, are there any other spaces besides blank spaces?
|
12-18-2018, 06:32 AM | #12 |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
|
12-19-2018, 06:58 AM | #13 |
Banned
Posts: 168
Karma: 10010
Join Date: Oct 2018
Device: Tolino/PRS 650/Tablet
|
I would like to have seven red lines, some painted with red ink, some with green ink and some with transparent ink.
"The experts, Youtube" |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Writing spaces for regex | roger64 | Sigil | 10 | 12-05-2017 09:26 PM |
regex - issue with spaces? | cybmole | Editor | 43 | 12-31-2013 12:49 PM |
How to remove blank spaces? | Mamaijee | Conversion | 2 | 04-09-2013 11:20 AM |
Blank spaces after header is removed | Mamaijee | Conversion | 2 | 05-26-2011 01:17 PM |
Missing blank spaces in ToC | richough3 | ePub | 3 | 09-10-2009 05:33 PM |