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 8624131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:26:57+00:00 2026-06-12T07:26:57+00:00

I just want this function to return an int back based on a string

  • 0

I just want this function to return an int back based on a string but its not working
It will be either H or V followed by 1 or 2 digits.

IE: H1         return 99
    H09        return 91
    H10        return 90
    H50        return 50
    V1         return 1
    V05        return 5
    V11        return 11
    V50        return 50

spot will be my string thats going in.

get100YardVersionEugene: function(spot)
{
        var team = spot.match(/[A-Z]+/);
        var yard = spot.match(/([0-9]+)/);

        if (team == "H")
        {
            return 100-yard;
        }
        else //V
        {
            return yard;
        }
    },

for some reason when its V9(or H9) it breaks but when i put in V09 it works.

Can someone tell me why?

EDIT: it breaks as in…
I have two variables start and end

so i have something like
start = get100YardVersionEugene(“V9”)
and I use start and end to draw it on html5 canvas

start = get100YardVersionEugene(“V9”) //doesn’t draw correctly
start = get100YardVersionEugene(“V09”) // draw correctly

  • 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-12T07:26:58+00:00Added an answer on June 12, 2026 at 7:26 am

    You can simplify your regex a little so it only checks for H or V.

    regarding the number, you need to remember that match returns an Array, so you’ll need to get the value by index. Also, you shouldn’t need the capture group.

    And actually, you should really just use one regex.

    get100YardVersionEugene: function(spot)
    {
         var parts = spot.match(/(H|V)([0-9]+)/);
         if (parts) {
            if (parts[1] == "H")
            {
                return 100-(+parts[2] || 0);
            }
            else //V
            {
                return +parts[2];
            }
        }
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this function: preg_match_all('/((\d{9})\.html)/s', $content, $results); It works fine but i just want
Normally someone would just go and grab Boost's Function Output Iterator but I'm not
I just want to design this very simple website. Basically there are multiple pages
I just want to know why this doesn't work (I am trying to name
i just want to know a general information about this particular information. Any good
i just want to find out the name of this grid to refresh it.
I just want to have other opinions about this one that I have been
I just want to ask if anybody has done something like this. Basically, it's
This is a basic security app and i just want to encrypt & decry-pt
I can't seem to find an answer on this and just want to make

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.