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. Regular Expression

Regular Expression

Scheduled Pinned Locked Moved JavaScript
regexquestion
3 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
    AB7771
    wrote on last edited by
    #1

    Hi all, I have scenario where a string can contain '$' only at the start, I was able to create a regular expression for this validation, but now another scenario is the same string can be repeated by a ',' delimiter. Now what happens is since I don't allow the '$' in the string except for the first position, when I repeat the same string after ',' starting with '$' the validation fails. Is there anyway in which we can restrict a character uptil some delimiter and then again allow it? Any pointers would be appreciated.

    Thanks & Regards, Pramod "Everyone is a genius at least once a year"

    V A 2 Replies Last reply
    0
    • A AB7771

      Hi all, I have scenario where a string can contain '$' only at the start, I was able to create a regular expression for this validation, but now another scenario is the same string can be repeated by a ',' delimiter. Now what happens is since I don't allow the '$' in the string except for the first position, when I repeat the same string after ',' starting with '$' the validation fails. Is there anyway in which we can restrict a character uptil some delimiter and then again allow it? Any pointers would be appreciated.

      Thanks & Regards, Pramod "Everyone is a genius at least once a year"

      V Offline
      V Offline
      vinodkumarnie
      wrote on last edited by
      #2

      Explanation is not enough in all situations. So Please give some string examples.. Thank you..

      Vinod Kumar B C Software Engineer

      1 Reply Last reply
      0
      • A AB7771

        Hi all, I have scenario where a string can contain '$' only at the start, I was able to create a regular expression for this validation, but now another scenario is the same string can be repeated by a ',' delimiter. Now what happens is since I don't allow the '$' in the string except for the first position, when I repeat the same string after ',' starting with '$' the validation fails. Is there anyway in which we can restrict a character uptil some delimiter and then again allow it? Any pointers would be appreciated.

        Thanks & Regards, Pramod "Everyone is a genius at least once a year"

        A Offline
        A Offline
        AspDotNetDev
        wrote on last edited by
        #3

        Keep in mind that "$" is a special character, so you must escape it. The regular expression would look something like this:

        ^\$?((?!\$).)+(,\$?((?!\$).)+)*$

        FYI, the tricky bit is called a "negative lookahead".

        Thou mewling ill-breeding pignut!

        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