Removing date from string

I have strings like:




I want to extract the date, which is always in format YYY-MM-DD. I can use grepstr to check whether the string contains a date in this format. But how can I find the location in the string of the date, or somehow extract it? greplist won't cover the cases where the separator is not something standard like "_". And I can't use strSearch because I don't know of a wildcard character specifically for digits. Or maybe it's possible to search for a digit using one of the str functions?


This function will give you the date from any string if the date is in the format YYYY-MM-DD:

Function/S ExtractDate(string in)
    string out
    SplitString/E=("([0-9]{4}-[0-9]{2}-[0-9]{2})") in, out
    return out


print ExtractDate("S9051D2022-02-11test")