LaRetta Posted September 6, 2017 Posted September 6, 2017 I am converting field names to values in a text field. Field names are similar to: FacilitySizeApproxImpervious For the data, I want: Facility Size Approx Impervioius What is the best way to identify the capital letter and add a space before it (but obviously not the first capital letter)? Thank you for any assistance. By the way, I have this started: Let ( field = table::FieldName Substitute ( field ; [ "A" ; " A" ] ; [ "B" ; " B" ] ; [ "C" ; " C" ] But I wonder if there is a better way and that also replaces the first one.
comment Posted September 6, 2017 Posted September 6, 2017 (edited) I don't think there's a shorter way = Trim ( Substitute ( text ; ["A" ; " A" ] ; ["B" ; " B" ] ; ["C" ; " C" ] ; ["D" ; " D" ] ; // ... ["X" ; " X" ] ; ["Y" ; " Y" ] ; ["Z" ; " Z" ] ) ) Hopefully you don't have any accented or Greek capital letters. Edited September 6, 2017 by comment 1
LaRetta Posted September 6, 2017 Author Posted September 6, 2017 Bingo! Apply it and THEN removing the fist space! Thank you so much!
LaRetta Posted September 6, 2017 Author Posted September 6, 2017 27 minutes ago, comment said: Hopefully you don't have any accented or Greek capital letters. Since they are field names, there shouldn't be; same with $# etc. I anticipate the Users will have to review and correct some of them anyway but I want them to have a good start on the basic 'question labels.'
comment Posted September 6, 2017 Posted September 6, 2017 49 minutes ago, comment said: I don't think there's a shorter way Well, that is unless you're willing to use a plugin: BE_RegularExpression ( "AlphaBravoCharlie" ; "(\p{Lu})" ; "g" ; " $1" ) will return: " Alpha Bravo Charlie" and will recognize any uppercase characters, in any language. 1
LaRetta Posted September 6, 2017 Author Posted September 6, 2017 WOW. I hadn't created the calc yet and I am very willing to use Base Elements plugin since we use it all the time! YOU ROCK! That worked perfectly!
comment Posted September 7, 2017 Posted September 7, 2017 (edited) Even better = BE_RegularExpression ( "AlphaBravoÇharlie" ; "(\p{Ll})(\p{Lu})" ; "g" ; "$1 $2” ) returns: "Alpha Bravo Çharlie" Basically, this looks for a lowercase character (excluding punctuation and digits) followed by an uppercase one, and inserts a space between them. Edited September 7, 2017 by comment 1
Recommended Posts
This topic is 2646 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now