GREP search within and If-Then-Else action possible?

I need KM to evaluate the contents of any given cell of a spreadsheet and perform different actions depending on if the cell contains time stamps, text or is empty.

Specifically, I pasted into a spreadsheet data from a WebVTT file (reference) which I need to work on.

Screenshot below with timestamps in yellow:

2022-09-04_18-19-31

I was able to figure out how to make KM evaluate if the cell contains text or is empty but cannot make it work to detect if the cell contains a timestamp (e.g., 00:00:11.304 --> 00:00:13.761).

My first thought was "maybe there's a way to use a GREP evaluation function inside an If-Then-Else Action but it doesn't seem possible.

Note: I think the simple and easy way to do this is to detect if the cell contains "-->" but I'd still like to know for future reference is GREP is possible inside an If-Then-Else.

I have to do a lot of repetitive work so I'm hoping KM can do this.

Thanks!

1 Like

Yes, use "matches" ("does not match" is also available).

km

See also the "switch/case" action.

K

While @kevinb's given you the answer, I'll also point you to the Text Conditions page on the Wiki so so you can see what the options in that pop-up mean.

All the various conditions you can use in an "If Then Else" action are linked to from the action's page and you'll see that there are a lot of things you can test against.

And I'd add a general shout out for the manual itself -- the wiki pages sometimes assume you already know some of the concepts in the manual like the different field types, variables, tokens, etc. Even if you just skim it you'll have an idea of where to look when you have a question.

That's not to put you off asking here, but sometimes a 5 minute read will save you waiting 10 hours for an answer on the Forum!

1 Like

... If only I had a dollar for every time I've (re-)learned that lesson... and not just here but life in general :grinning:

I understand why you would think I didn't read. I did, but I couldn't find this info.

1 Like

Apologies -- I didn't mean to imply that you hadn't tried to find out for yourself. There's a lot documentation for (and online help in) KM but, perhaps because of that, it's sometimes difficult to find the answer you need! I've found that 5 minutes here and there might not answer the current question but it does help later when you have a "Didn't I see mention of...?" moment -- or just help me rephrase the question in the way the documentation expects.

And don't forget the help within KM itself. Each action has a "help" item in their "cogwheel" that takes you to their wiki page, and holding down the Option key while choosing items in the "Insert" menu or new triggers/conditions/collections will reveal a bunch more links.

I should really have put it the other way round -- there's loads of documentation, but if you haven't found what you need after 5 minutes then don't hesitate to ask here!