Tinderbox Forum

Extracting a date from $Text via Regex into a Key Attribute possible?

I’d like to make a KA from a date in a text.
Now I have a regex like this:

but I don’t find the right code to get it into the KA.

With String.replace I can delete the date, but I want to have only the date and discard the rest…

Yes: this is easily done, provided that the date is parseable either by Tinderbox or by macOS.

Make an agent that searches for a pattern with a back-expression:

Agent query: Text.contains("Datum: (.+)")

This will bind the temporary value $1 to the first matched sub-expression, and you can assign that to a date

Agent action: $StartDate=$1;

\d{1,2}. [a-zA-Z]{3,9} [0-9]{4} um \d{2}:\d{2}:\d{2} MESZ as well as
"Datum: (.+)$"

always create the actual time.
Without the $ the result was some text in the lines after “Datum”…

Another approach to avoid the regex reading further into $Text:

$Text.contains("Datum: ([^\n]+)")

$1 now holds one or more characters that are not a line break (i.e. capture to the end of the line).

That works like a charm!
Thanks a lot :slight_smile: