javascriptjqueryregexserver-application

using javascript regexp to match log file tail


hi I need to use regex to vaildate an ajax call to an output log on a server - to check if a process therin is "finished". I have a php file that can give the last line of the log no mater what. Ajax goes and gets it 5 times a second. But I need to client side ratify it when done. The last line of the log (when finished) will be:

Just like any of these examples either "Total time: 2 seconds" or "Total time: 17 seconds" or "Total time: 1 minutes" I would like a regex to be able to identify that string no matter what the number


Solution

  • /Total time: \d{1,} (seconds|minutes)/

    you can add an upper limit after the 1, if you'd like to limit the number to 2-4 digits or whatever you want.