最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Is there a combination of functions on google sheets that can proper a list of words but also apply exceptions for abbreviations

programmeradmin1浏览0评论

I need to apply the =proper function to a list of job titles but also apply exceptions to certain words like ABM, CEO, etc. What should I do?

=ARRAYFORMULA(IF(A1:A<>"", TEXTJOIN(" ", TRUE, IF( REGEXMATCH(TEXT(SPLIT(A1:A, " ")), "(?i)^(JP|AASM|CEO|NASA|J.P.|FBI|US|ABM|AAST|AE)$"), UPPER(SPLIT(A1:A, " ")), PROPER(SPLIT(A1:A, " ")) ))), ""))

This was the code I tried using, but Sheets gave me this error: "It looks like your formula is missing one or more open parentheses. If you don't want to enter a formula, begin your text with an apostrophe (')." I removed the parentheses, or the ones that were highlighted red, to ->

=ARRAYFORMULA(IF(A1:A<>"", TEXTJOIN(" ", TRUE, IF( REGEXMATCH(TEXT(SPLIT(A1:A, " ")), "(?i)^(JP|AASM|CEO|NASA|J.P.|FBI|US|ABM|AAST|AE)$"), UPPER(SPLIT(A1:A, " ")), PROPER(SPLIT(A1:A, " ")) ))), "")

And google Sheets gave me this error: " #N/A: Wrong number of arguments to ARRAYFORMULA. Expected 1 argument, but got 2 arguments."

Job Title header 2
CEO DATA Management CEO Data Management
STUART LI Stuart Li
AAPM AAPM

I need to apply the =proper function to a list of job titles but also apply exceptions to certain words like ABM, CEO, etc. What should I do?

=ARRAYFORMULA(IF(A1:A<>"", TEXTJOIN(" ", TRUE, IF( REGEXMATCH(TEXT(SPLIT(A1:A, " ")), "(?i)^(JP|AASM|CEO|NASA|J.P.|FBI|US|ABM|AAST|AE)$"), UPPER(SPLIT(A1:A, " ")), PROPER(SPLIT(A1:A, " ")) ))), ""))

This was the code I tried using, but Sheets gave me this error: "It looks like your formula is missing one or more open parentheses. If you don't want to enter a formula, begin your text with an apostrophe (')." I removed the parentheses, or the ones that were highlighted red, to ->

=ARRAYFORMULA(IF(A1:A<>"", TEXTJOIN(" ", TRUE, IF( REGEXMATCH(TEXT(SPLIT(A1:A, " ")), "(?i)^(JP|AASM|CEO|NASA|J.P.|FBI|US|ABM|AAST|AE)$"), UPPER(SPLIT(A1:A, " ")), PROPER(SPLIT(A1:A, " ")) ))), "")

And google Sheets gave me this error: " #N/A: Wrong number of arguments to ARRAYFORMULA. Expected 1 argument, but got 2 arguments."

Job Title header 2
CEO DATA Management CEO Data Management
STUART LI Stuart Li
AAPM AAPM
Share Improve this question asked Feb 10 at 23:54 William WillWilliam Will 111 silver badge1 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 1

Try this out:

=ARRAYFORMULA(
   MAP(A2:A, LAMBDA(a,
     IF(a = "", , LET(
      s, SPLIT(a, " "),
      ex, "CEO|AAPM",
      JOIN(" ",
        IF(
          REGEXMATCH(s, "^(" & ex & ")$"),
          s,
          PROPER(s)
        )
      )
     ))
   ))
 ) 

Applying Proper Function on Selected words on a String

You can also try this another approach. Using Reduce to Iterate through the words.

Formula

=Byrow(A1:A, LAMBDA(r, IF(ISBLANK(r),"",REDUCE(,SPLIT(r, " "), LAMBDA(a,c, IFNA(IF(MATCH(c, SPLIT("JP|AASM|CEO|NASA|J.P.|FBI|US|ABM|AAST|AE|AAPM","|"),0)>0,JOIN(" ",a,c),), JOIN(" ",a,PROPER(c))))))))

Result

Sample Result
CEO DATA Management CEO Data Management
STUART LI Stuart Li
AAPM AAPM

References:

Reduce

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论