0
I need a regex statement to find any words formatted in CamelCase. Examples include:
- CamelCase.
- Trunk_Note.
- Med-Dr.Zung.
- _MyToDo-Housework.
- _MyToDo-Vacation_Cancun
- iOS_GReader
Key points:
- The first character can be any character that is valid in a Windows OS filename.
- Any character can be any character that is valid in a Windows OS filename including
.
. - The word will be delimited by a preceding
(space),
(
, or[
and followed by a(space),
)
, or]
.
Why? I use an iOS app called Trunk Notes to maintain extensive notes on all aspects of my life (1000+ topics covering 10+ years of work, family, and personal content). Trunk Notes uses Markdown for content formatting but has a specific problem with my CamelCase words. When placed inside a link label or title, e.g. iOS_WriteRoom, the Markdown engine chokes and generates broken HTML. Underscores (_
) in the words also confuse the engine. The simplist solution is to precede the offending word with /
, e.g. /iOS_WriteRoom.
I began making manual edits but realize regex should work for me. So my regex solution will look for the matching pattern and prepend a /
if a /
has not already been prepended.
Thank you in advance for any suggestions.
2
Trunk_Note
andMed-Dr.Zung
are not camel case, they're snake case or mixed camel / snake case. The only camel case example you have is "CamelCase". The others contain underscores, dashes, or other punctuation to separate words, where camel case only uses capitalization:TrunkNote
,MedDrZung
,MyToDoHousework
,MyToDoVacationCancun
,iOSGReader
. Food for thought! – Darth Android – 2013-06-26T20:04:18.040