Recovering the date with Regexp_extract bigquery



  • rows containing the date in 01.10.2021 and the row may contain the text.

    Sold as follows

    REGEXP_EXTRACT(Дата когда записали, r'^[0-9]{2}[/\.][0-9]{2}[/\-][0.9]{4}$')
    

    and another option

    REGEXP_EXTRACT(Дата когда записали, '%d.%m.%Y')
    

    both returns null

    How can I fix it?



  • In regular terms, there should be an exciting underwear, otherwise REGEXP_EXTRACT Can't get the meaning back.

    In addition, if the date is not whole, the anchors cannot be used. ^ and $as they require the beginning or end of the line, respectively.

    [0.9] - it's a clear seal.

    Use it.

    REGEXP_EXTRACT(Дата когда записали, r'(?:\D|^)(\d{2}[-/.]\d{2}[-/.]\d{4})(?:\D|$)')
    

    See. https://regex101.com/r/vXMMZF/2 ♪

    Details

    • (?:\D|^) - the beginning of the line or a symbol different from the digital
    • (\d{2}[-/.]\d{2}[-/.]\d{4}) - Extractive No. 1: two digits, symbol -/ or .Two digits, symbol -/ or .4 digits
    • (?:\D|$) - End of line or symbol different from digital


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2