Home > database >  How to insert a Space before an Uppercase character using a formula or a script?
How to insert a Space before an Uppercase character using a formula or a script?

Time:07-14

As my title says, I am Working on Google Sheet and I am looking for a way to add spaces before Uppercase letters. I work on a SpreadSheet named "Object" in which there is a column - let's say that it is the Column A starting at the 3rd Row - with datas formatted as followed:

Title

Accreditation

ContractModel

ProductGroup

ObjectivesAndFeedback

...

As you can see, there can be several words in a cell and the first letter of each word begin with an Uppercase Character. I Am looking for a simple way to automate the insertion of spaces before any Uppercase character, except the first character of each cell, in the next column.

As an example:

ContractModel > Contract Model

ObjectivesAndFeedback > Objectives And Feedback

I am currently looking every youtube tutorial or shady Forums I can find without finding a simple solution that suits my condition given that I work on Sheet and only begin to use formulas. If you have any idea, you are more than welcome!

CodePudding user response:

Try

=TEXTJOIN(" ",,REGEXEXTRACT(A1,REGEXREPLACE(A1,"([A-Z][a-z] )","($1)")))

ou Applique cette fonction

function nomCamel(nom){
  return nom.replace(/([a-z])([A-Z])/g, '$1 $2')
}

enter image description here

CodePudding user response:

let s = "AxyzBxyxCxyz"
s.replace(/\w([A-Z])/g,' $1')

'Axy Bxy Cxyz'
  • Related