[Google 試算表] 透過 REGEXEXTRACT 來抓取文字中的正負號小數點數字
2024-09-12
紀錄一下最近常使用到的 Google Sheet 指令,因為最近在幫朋友製作他的 Google Sheet 表單
基於工程師的本能就想說直接用函數優化,但是畢竟比較少用,所以查了一下文件配合ChatGPT
就整理了一下紀錄一下 REGEXEXTRACT
1. 找尋文字中的數字(僅支持正數),這一題要透過 REGEX,這會忽略 - 這符號避免判斷成為負數
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=VALUE(REGEXEXTRACT(A15, "\d+\.?\d*")) | |
2.找尋文字中的數字(可以提取包含負數),主要是因為裡面資料有可能是正也有可能是負
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=VALUE(REGEXEXTRACT(A3, "-?\d+\.?\d*")) | |
先筆記到這邊,之後要來處理一些比較複雜的應用