![]() |
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 |
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 |
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) |
According to Wikipedia, the use of superscripts for ordinals in English should be avoided nowadays.
|
@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:smack: @Danger -- I'll try the suggestion tonight Paul |
Quote:
|
@Danger -- RegEx works very well
I was overthinking it Simpler is better Paul |
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). |
[removed, I was reading the "+" wrong]
|
Quote:
Hitch |
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. |
| All times are GMT -4. The time now is 10:27 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.