01-02-2013, 10:37 PM | #1 |
Wizard
Posts: 1,071
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
Struggling with RegEx
Not having ANY luck getting a RegEx to work right
Need 1. Break 'joined words with single UC letter inside: lowerCase --> lower+Case ( the + is really a space char) LowerCase --> Lower+Case ( the + is really a space char) Need 2. Superscript ordinal suffixes 89th --> 89<sup>th</sup> 1st --> 1<sup>st</sup> Thanks Paul |
01-03-2013, 12:51 AM | #2 |
Evangelist
Posts: 490
Karma: 1665031
Join Date: Nov 2010
Location: Vancouver Island, Nanaimo
Device: K2 (retired), Kobo Touch (passed to the wife), KGlo, Galaxy TabPro
|
You could try the following...
Need 1: Find: ([a-z])([A-Z]) Replace: \1+\2 Where + is really a space Need 2: Find: ([0-9])([a-z])([a-z])+ Replace: \1<sup>\2\3</sup>+ Where + is really a space |
01-03-2013, 12:54 PM | #3 | |
♫
Posts: 660
Karma: 506380
Join Date: Aug 2010
Location: Germany
Device: Kobo Aura / PB Lux 2 / Bookeen Frontlight / Kobo Mini / Nook Color
|
Quote:
I use find: (\s[0-9]+)(st|nd|rd|th)\s replace: \1<sup>\2</sup>\s Did I miss any (st|nd|rd|th) in my find statement? (not my native language) |
|
01-03-2013, 01:57 PM | #5 | ||
Wizard
Posts: 1,071
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
@Jellby --
Quote:
Quote:
I'll also turn it off in my MS Word also I will keep the RegEx and probably use it as a starting point for other things. However, the most frustrating editing task right now is 'Need #1' to insert a space for text like "JohnSmith" (s/b "John Smith") and "missingLink" (s/b "missing Link"). I have no idea how so many words got joined @Danger -- I'll try the suggestion tonight Paul |
||
01-03-2013, 03:25 PM | #6 |
Evangelist
Posts: 490
Karma: 1665031
Join Date: Nov 2010
Location: Vancouver Island, Nanaimo
Device: K2 (retired), Kobo Touch (passed to the wife), KGlo, Galaxy TabPro
|
While that might be dangerous. That search will only find any 2 lowercase letters that follow a number and have a space trailing them. So 50mph would not be picked up as it doesn't fit the criteria. Not saying it's fool proof though
|
01-03-2013, 10:29 PM | #7 |
Wizard
Posts: 1,071
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
@Danger -- RegEx works very well
I was overthinking it Simpler is better Paul |
01-04-2013, 01:42 PM | #8 |
Evangelist
Posts: 416
Karma: 1045911
Join Date: Sep 2011
Location: Cape Town, South Africa
Device: Kindle 3
|
When in doubt : RegexBuddy
Really cant recommend it enough, tho it might be closed and windows-centric, it's got no equal. (ok there's a pretty good tk tool similar, but it's very tricky for most to use). |
01-05-2013, 04:50 AM | #9 |
♫
Posts: 660
Karma: 506380
Join Date: Aug 2010
Location: Germany
Device: Kobo Aura / PB Lux 2 / Bookeen Frontlight / Kobo Mini / Nook Color
|
[removed, I was reading the "+" wrong]
Last edited by WS64; 01-05-2013 at 04:54 AM. |
01-06-2013, 03:52 AM | #10 |
Bookmaker & Cat Slave
Posts: 11,462
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
|
01-13-2013, 02:00 AM | #11 |
Addict
Posts: 320
Karma: 56788
Join Date: Jun 2011
Device: Kindle
|
you may want to be careful with the lowercase-upper separator, as it will match (and modify) body text such as "McDonalds" and html code such as "preserveAspectRatio" and "viewBox".
I use something like: Code:
(?<!Mac|Mc)(?<=\p{Ll})\p{Lu}(?!spect|atio|ox[=]) you could add parentheses around "\p{Lu}" and set the replace value as "[blank space]\1", but again, i would still recommend cycling through each instance individually. Last edited by ElMiko; 01-13-2013 at 02:10 AM. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
really struggling and need help! | kirubiru | Calibre | 1 | 11-22-2011 09:28 PM |
Struggling with one website | sorcer | Recipes | 7 | 02-14-2011 09:35 AM |
Unutterably Silly To all struggling with their Ph.D. | LCF | Lounge | 2 | 02-11-2011 08:02 PM |
Struggling with CLI | Paulinafrica | Calibre | 4 | 01-08-2011 02:04 PM |
struggling with calibre | aprilquilts | Amazon Kindle | 9 | 12-19-2010 03:05 AM |