Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8095517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:09:26+00:00 2026-06-05T21:09:26+00:00

I am analyzing timestamped YouTube comments. Because some comments may refer to a period

  • 0

I am analyzing timestamped YouTube comments. Because some comments may refer to a period in either mm:ss, m:ss, hh:mm:ss, or h:mm:ss, I need to prepare for these cases. The following code works on mm:ss and m:ss, but still treats the one with hours as if it was mm:ss. For example, 02:24:30 returns 144, as it is only analyzing the first two parts. Here is the code:

var timePattern = /(([0-5][0-9])|[0-9])\:[0-9]{2,2}/;
var seconds = "";

for (var i = 0; i < comments.length; i++) {
    var matches = comments[i].match(timePattern);
    var matched = matches[0];
    var a = matched.split(':');
    if(matched.length == 7 || matched.length == 8) {
        seconds = (+a[0])*60*60 + (+a[1])*60 + a[2];        
    } else {
        seconds = (+a[0])*60 + (+a[1]); 
    }
    times.push(seconds);
}   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:09:28+00:00Added an answer on June 5, 2026 at 9:09 pm

    Try a different regex.

    (?:([0-5]?[0-9]):)?([0-5]?[0-9]):([0-5][0-9])
    

    First contains hours, second contains minutes, last contains seconds.

    Hours will be empty if no hours are found.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After analyzing my issue, I think I may need to use the union operator
Consider the following Ruby code analyzing a three-byte UTF-8 string: #encoding: utf-8 s =
I'm analyzing the TCP traffic behavior in LTE network, and need to find out
When i am analyzing it getting these messages: Method returns an Objective-C object with
I'm analyzing some code that utilizes empty OVER clauses in the contest of Count().
While analyzing some approaches to making our web app easier to deploy on our
I was analyzing my situation and I face with the problem that I need
I am analyzing the following piece of code using a static analysis tool called
We have a posting analyzing requirement, that is, for a specific post, we need
Hello I am analyzing some data and trying to use a package that contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.