英文:
Search two values in a single cell and return the position of the first one found
问题
=LEFT(C3180, IF(ISNUMBER(FIND(" ", C3180)), FIND(" ", C3180), FIND(CHAR(10), C3180))-1)
英文:
I have a column in Google Sheets where every cell in that column contains two words, i'm looking for some formula to extract only the first word, knowing that sometimes there is space between the two words and sometimes there is back to line instead of space.
I have tried this :
=LEFT(C3180, FIND(" ", C3180)-1)
And it worked in cells where there is a space between the two words.
I also tried this :
=LEFT(C3180, FIND(CHAR(10), C3180)-1)
And it worked in cells where there is back to line between the two words.
Finally i have tried this but it doesn't work :
=LEFT(C3180, FIND(OR(" ",CHAR(10)), C3180)-1)
答案1
得分: 0
这是一种方法:
=regexextract(A2,"(.*)(?: |\n)")
答案2
得分: 0
Sure, here are the translated parts:
你可以在每个单元格中尝试以下任一公式:
=REGEXEXTRACT(B2:B31,"[a-zA-Z]+")
或者
=REGEXEXTRACT(B2:B31,"[[:alpha:]]+")
另一种方法是可以使用一个公式来处理整个范围:
=INDEX(IFERROR(
REGEXEXTRACT(B2:B31,"[a-zA-Z]+")))
(请根据您的范围和区域设置调整每个公式)
英文:
You can try -in each cell- either of
=REGEXEXTRACT(B2:B31,"[a-zA-Z]+")
OR
=REGEXEXTRACT(B2:B31,"[[:alpha:]]+")
On the other hand, one can use a single formula for a whole range
=INDEX(IFERROR(
REGEXEXTRACT(B2:B31,"[a-zA-Z]+")))
(Do adjust each formula according to your ranges and locale)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论