|
|
#1 |
|
Connoisseur
![]() Posts: 82
Karma: 10
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: kindle
|
Struggling with RegEx
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 |
|
|
|
|
|
#2 |
|
KT Ads, NO THANKS!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 389
Karma: 1018357
Join Date: Nov 2010
Location: Vancouver Island, Nanaimo
Device: K2 (retired), Kobo Touch (passed to the wife), KGlo
|
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 |
|
|
|
|
Enthusiast
|
|
|
|
#3 | |
|
♫
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 326
Karma: 504884
Join Date: Aug 2010
Location: Germany
Device: Bookeen Frontlight / Kindle 3 / Kobo Touch / Ipod touch / 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) |
|
|
|
|
|
|
#5 | ||
|
Connoisseur
![]() Posts: 82
Karma: 10
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: kindle
|
@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 |
||
|
|
|
|
|
#6 | |
|
KT Ads, NO THANKS!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 389
Karma: 1018357
Join Date: Nov 2010
Location: Vancouver Island, Nanaimo
Device: K2 (retired), Kobo Touch (passed to the wife), KGlo
|
Quote:
|
|
|
|
|
|
|
#7 |
|
Connoisseur
![]() Posts: 82
Karma: 10
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: kindle
|
@Danger -- RegEx works very well
I was overthinking it Simpler is better Paul |
|
|
|
|
|
#8 |
|
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 415
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). |
|
|
|
|
|
#9 |
|
♫
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 326
Karma: 504884
Join Date: Aug 2010
Location: Germany
Device: Bookeen Frontlight / Kindle 3 / Kobo Touch / Ipod touch / Nook Color
|
[removed, I was reading the "+" wrong]
Last edited by WS64; 01-05-2013 at 04:54 AM. |
|
|
|
|
|
#10 | |
|
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,095
Karma: 6245217
Join Date: Apr 2010
Location: Phoenix, AZ
Device: Kindle2, iPad, KindleFire and NookColor
|
Quote:
Hitch
__________________
I produce eBooks. www.booknook.biz Follow us on Twitter "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair |
|
|
|
|
|
|
#11 |
|
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 286
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.
__________________
When some wild-eyed, eight-foot-tall maniac grabs your neck, taps the back of your favorite head up against the barroom wall, and he looks you crooked in the eye and he asks you if you've paid your dues, well, you just stare that big sucker right back in the eye, and you remember what ol' Jack Burton always says at a time like that: "Have ya paid your dues, Jack?" "Yessir, the check is in the mail." Last edited by ElMiko; 01-13-2013 at 02:10 AM. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
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 |