添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Google Sheets Function: REGEXEXTRACT

Extracting the First Word Found

The REGEXEXTRACT function here returns the first word found among the two possibilities ("fun" or "terrifying"):

=REGEXEXTRACT(A2,"fun|terrifying")

Extracting a Reference

This time, the REGEXEXTRACT function returns the part of the reference number matching the expression "[A-Z]\d{2}" (i.e., an uppercase letter followed by 2 digits):

=REGEXEXTRACT(A2,"[A-Z]\d{2}")

Extracting a Number

The regex "\d*" corresponds to "all digits in unlimited quantity," meaning the function will extract all digits until encountering a non-digit character:

=REGEXEXTRACT(A2,"\d*")

Extracting at the End

To extract the digits at the end of the text this time, add a "$" to the end of the regex:

=REGEXEXTRACT(A2,"\d*$")

Extracting Multiple Parts

To extract the different groups of numbers, add parentheses around each part of the text to extract:

=REGEXEXTRACT(A2,"(\d*)-?(\d*)-?(\d*)-?(\d*)")

Extracting in the Middle

For example, to extract the second group of numbers, the regex is as follows:

=REGEXEXTRACT(A2,"(?:(\d*)-?){2}")

The addition of "?:", after the first parenthesis indicates it is non-capturing (so it won't return any value). There is then only one pair of parentheses left (thus only one value returned) and a quantifier of 2: