[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: splitting camel case?
- From: David Gish <david@...>
- Date: Sat, 14 Jan 2006 12:10:09 -0600
Here is what I have presently:
( "componentWithName" ):gsub( "%u?%l+", print )
> component
> With
> Name
However this doesn't quite cover all potential cases, specially
acronyms (e.g. "componentWithURL"):
Such limitations are inherent to "camel case" (aka "inner-caps"). For
example, there is no way to parse "componentWithURLAndParameters" with
a simple regular expression. The solution is to use a limited
dictionary containing "URL" and any other problematic tokens. Then you
parse in two phases:
1. Parse dictionary terms:
"componentWithURLAndParameters" ->
> "componentWith"
> "URL" (flag as dictionary term)
> "AndParameters"
2. Parse "camel" cases for each resulting token into a secondary
buffer, passing dictionary terms unchanged:
> "component
> "With"
> "URL"
> "And"
> "Parameters"
Cheers,
David Gish
Senior Systems Engineer
Aspyr Media
www.aspyr.com