Search code examples
libreoffice-calc

Libreoffice Calc REGEX how get second match?


How get second match of REGEX? For example:

A1: 11:33

=REGEX(A1;"\d{2}") - gets 11, but I want 33!


Solution

  • You can try to capture the second pair of digits (that's the one after the first) and replace everything with the captured value.

    =REGEX(A1,"^.*?\d{2}.*?(\d{2}).*$","$1")
    

    Edit:

    From your comment on the other answer it seems like you don't have a string but a time. In that case regex is the wrong tool. Simply use MINUTE() to extract the minute portion of a time:

    =MINUTE(A1)