Removing Capital Letters between brackets on google sheets - google-sheets

on google sheets I am trying to remove some capital letters that exist between brackets using regexreplace
=arrayformula(regexreplace(regexreplace(A2:A,"\(.+?\)\ Ltd$| $| LTD$","")," $| LTD$",))
the only part remaining is where it could be random company (PTY) and I need to remove the space before the (PTY) and the (PTY).
any ideas?

Try this formula:
=arrayformula(regexreplace(A2:A,"\s?\(.+\) (Ltd|LTD)$",""))
Output:
Reference:
Regex capturing group

Related

Trying to remove all text within Parentheses and remove parentheses as well as well as Turn all the capital letters except Except the first letter

I have a google sheet with a list of names that I am trying to apply my existing formula to. There are some names that have parentheses with text within those parentheses as well as some names that are all captial letters. I want to remove the parentheses and the text within as well having only the first letter of each name capitalized written into a formula. My existing formula removes the parenthese, dashes and quotation marks which I want to keep it that way, but now I am just wantint to add onto that formula all together for what I stated above. I will also link my practice google sheet so you can see where I am applying the formula.
Formula: =ARRAYFORMULA(TRIM(REGEXREPLACE(C4:C411,"-|'|,|(|)|"""," ")))
Practice Formula Sheet
If the doc is not accessible here is photo of what it looks like
I was trying to use an older version of this formula i.e: =REGEXREPLACE(C4:C411,"([^()]*)","").
This does remove the parentheses with the text inside as well but thats it. I need to remove the parentheses as well as the text within those parentheses and the names that are all captial letters. I want to remove the parentheses and the text within as well having only the first letter of each name capitalized written into a formula.
can you try this:
=ARRAYFORMULA(PROPER(TRIM(REGEXREPLACE(REGEXREPLACE(A:A,"\(.*?\)",""),"[^\w\s]"," "))))
try:
=INDEX(TRIM(REGEXREPLACE(REGEXREPLACE(A25:A28,
"['-]", " "), "[^A-Za-z ]", )))
you can add PROPER, LOWER or UPPER if you need so:
=INDEX(PROPER(TRIM(REGEXREPLACE(REGEXREPLACE(A25:A28,
"['-]", " "), "[^A-Za-z ]", ))))

Capitalize only words with more than 2 characters on Google Sheets

How can I capitalize only words with more than a specific count of characters? Google Sheets formula PROPER capitalizes all the words without any exclusions. For example, I would like to omit the capitalization of an acronym such as "PC" or "RAM" that is contained within a string in a cell.
Capitalize All and exclude from a list
To be able to PROPER()/Capitalize the input of words and exclude others:
Use this formula, but first we need the excluded list "Acronyms excluded".
=ArrayFormula(IF(
REGEXMATCH(TEXTJOIN("^_~",,UNIQUE($D$2:$D)), UPPER(A2:A))<>TRUE,PROPER(A2:A),A2:A))
Capitalize only words more than 2 charachters long
=ArrayFormula(IF(A2:A="",,
IF(LEN(UPPER(A2:A))<=2,
UPPER(A2:A),PROPER(A2:A))))
I may have been overthinking this by a mile, but try:
Formula in B1:
=INDEX(SUBSTITUTE(TEXTJOIN("",0,IF(LEFT(SPLIT(REGEXREPLACE(A1,"\b(RAM|[A-Za-z]{1,2})\b","|♣$1|"),"|"))="♣",SPLIT(REGEXREPLACE(A1,"\b(RAM|[A-Za-z]{1,2})\b","|♣$1|"),"|"),PROPER(SPLIT(REGEXREPLACE(A1,"\b(RAM|[A-Za-z]{1,2})\b","|♣$1|"),"|")))),"♣",""))
The point here is that \b(RAM|[A-Za-z]{1,2})\b would capture any 1-2 character word made of word-characters between word-boundaries or RAM. Now you can add any exclusion into the alternation of the pattern through concatenating more |. The replacement includes a backreference to the capture group to encapsulate the substring between a delimiter to split on and a leading unique character. The IF() will then check whether or not any element from the resulting SPLIT() needs to be processed with Proper() or not.
Note: Word-boundaries like \b may not be safe when you'd have data like hello-pc and you'd want this to be processed with PROPER(). A small adjustment to the formula is then needed.

Trim Space on left Google sheets

I have this formula on Google sheets:
=ARRAYFORMULA(IFERROR(IF(ISBLANK(A2:A),SPLIT(REGEXREPLACE(C2:C,",","+VITAMIN "),"+"),SPLIT(A2:A,"+"))))
How do i remove spaces on left after my split?
You can see example in column F in this example:
https://docs.google.com/spreadsheets/d/15ZU_mUrnTvhssgHF231dHKFjjsD7t_0pEFm0ysKoL6A/edit#gid=0
For example, how about using TRIM as follows?
Modified formula:
=ARRAYFORMULA(TRIM(IFERROR(IF(ISBLANK(A2:A),SPLIT(REGEXREPLACE(C2:C,",","+VITAMIN "),"+"),SPLIT(A2:A,"+")))))
and
=ARRAYFORMULA(IFERROR(IF(ISBLANK(A2:A),TRIM(SPLIT(REGEXREPLACE(C2:C,",","+VITAMIN "),"+")),TRIM(SPLIT(A2:A,"+")))))
Reference:
TRIM

Extract all matches in a string using REGEXEXTRACT in Google Sheets

I have a cell with values like so: aasdf123asdf34asdf3
I want to extract all groups of consecutive numbers: 123, 34, and 3.
I think this is the regular expression I need: (\d+).
But it is only extracting the first match.
This works outside of Google Sheets. Not sure why I can't get it to work in Google Sheets.
https://regexr.com/572et
You could try actually generating the CSV string you want directly, using REGEXREPLACE:
=REGEXREPLACE(REGEXREPLACE("aasdf123asdf34asdf3", "\D+", ","), "^,|,$", "")
The inner call to REGEXREPLACE replaces all clusters of non digit characters with comma. The outer call then removed any leading/trailing commas which the first replacement might have left behind.
Moreover you can use SPLIT to separate the values into each individual cell:
=TRANSPOSE( SPLIT(REGEXREPLACE(REGEXREPLACE("aasdf123asdf34asdf3", "\D+", ","), "^,|,$", ""), ","))
In here the TRANSPOSE function is just to stack the matches vertically instead of horizontally as SPLIT would lay them as default.

Regex for array in Google Sheets

How do I remove non-numerical characters from a filter in Google Sheets?
I have a function that spits out matching phone numbers into up to 3 subsequent columns. I would like to eliminate non-number characters and a prevailing 1 if there is one, possibly using Regex.
=array_constrain(transpose(filter(People!H:H,People!B:B=A10)),1,3)
=ARRAYFORMULA(IFERROR(REGEXREPLACE(TO_TEXT(A1:A), "\D+|^1", "")))

Resources