Jump to content

A space before each Capital Letter


This topic is 2421 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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.

Link to comment
Share on other sites

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 by comment
  • Like 1
Link to comment
Share on other sites

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.'  

Link to comment
Share on other sites

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.

 

  • Like 1
Link to comment
Share on other sites

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 by comment
  • Like 1
Link to comment
Share on other sites

This topic is 2421 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.