Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Javascript Regex validation

Javascript Regex validation

Scheduled Pinned Locked Moved JavaScript
regexjavascripthelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arunkumar Koloth
    wrote on last edited by
    #1

    Hello, I am using regex to validate some patterns in javascript My pattern is

    [VF][0-9]

    And required output is V1-V9 , F1-F9 in any order (eg:V1,V3,V2,F1,F5,F3) OR (eg: F1,F5,F3,V1,V3,V2) But it is not working can any one help me? Thanks and regards.

    Kornfeld Eliyahu PeterK 1 Reply Last reply
    0
    • A Arunkumar Koloth

      Hello, I am using regex to validate some patterns in javascript My pattern is

      [VF][0-9]

      And required output is V1-V9 , F1-F9 in any order (eg:V1,V3,V2,F1,F5,F3) OR (eg: F1,F5,F3,V1,V3,V2) But it is not working can any one help me? Thanks and regards.

      Kornfeld Eliyahu PeterK Offline
      Kornfeld Eliyahu PeterK Offline
      Kornfeld Eliyahu Peter
      wrote on last edited by
      #2

      You question is not clear. The regex provided will check if the string has an V or F (case sensitive) at the first position and then a digit (0-9). But the part of the 'required output' is confusing! What the input, what the output, what have you expected?

      I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

      "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

      A 1 Reply Last reply
      0
      • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

        You question is not clear. The regex provided will check if the string has an V or F (case sensitive) at the first position and then a digit (0-9). But the part of the 'required output' is confusing! What the input, what the output, what have you expected?

        I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

        A Offline
        A Offline
        Arunkumar Koloth
        wrote on last edited by
        #3

        Hello, My input is something like V1V2-V3-S-V4-F1 And I need to validate the given value contain any of V1 to V9 or F1 to F9 and S. eg: if user input V20V30-V12-S10-V20-F10 I have to show a error because only 1-9 is allowed. eg2: if user input R1R2-R3-S-R5-T6 I have to show a error because only V,S,F allowed And it is not mandatory to enter V/F but S is mandatory. I think it is clear now.

        Kornfeld Eliyahu PeterK M 2 Replies Last reply
        0
        • A Arunkumar Koloth

          Hello, My input is something like V1V2-V3-S-V4-F1 And I need to validate the given value contain any of V1 to V9 or F1 to F9 and S. eg: if user input V20V30-V12-S10-V20-F10 I have to show a error because only 1-9 is allowed. eg2: if user input R1R2-R3-S-R5-T6 I have to show a error because only V,S,F allowed And it is not mandatory to enter V/F but S is mandatory. I think it is clear now.

          Kornfeld Eliyahu PeterK Offline
          Kornfeld Eliyahu PeterK Offline
          Kornfeld Eliyahu Peter
          wrote on last edited by
          #4

          You may try this regex - http://www.regexper.com/#((%5BFV%5D%5B0-9%5D)%2B%5B%5E%5Cd%5D)[^]

          I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

          "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

          1 Reply Last reply
          0
          • A Arunkumar Koloth

            Hello, My input is something like V1V2-V3-S-V4-F1 And I need to validate the given value contain any of V1 to V9 or F1 to F9 and S. eg: if user input V20V30-V12-S10-V20-F10 I have to show a error because only 1-9 is allowed. eg2: if user input R1R2-R3-S-R5-T6 I have to show a error because only V,S,F allowed And it is not mandatory to enter V/F but S is mandatory. I think it is clear now.

            M Offline
            M Offline
            Member 11730963
            wrote on last edited by
            #5

            You need the pattern "[VF][1-9]-?$" Because V20 matchs [VF][1-9] as V2 Hope this will help you.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups