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. General Programming
  3. Regular Expressions
  4. workaround for negative lookbehind regular expression in Javascript

workaround for negative lookbehind regular expression in Javascript

Scheduled Pinned Locked Moved Regular Expressions
javascriptregexquestion
3 Posts 3 Posters 5 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.
  • E Offline
    E Offline
    Ehsan sarshar
    wrote on last edited by
    #1

    /\B(?

    Richard DeemingR P 2 Replies Last reply
    0
    • E Ehsan sarshar

      /\B(?

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Use a decent browser; it's only Internet Explorer and Safari that don't support lookbehind assertions. Regular expressions - JavaScript | MDN[^] Assertions - JavaScript | MDN[^] https://javascript.info/regexp-lookahead-lookbehind[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • E Ehsan sarshar

        /\B(?

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        The commonest way that people solve this for browsers that don't support this is to think in reverse. In other words, you reverse the string and the regular expression so that all you end up testing is the negative regular expression, rather than a lookbehind. This[^] is a great resource.

        Advanced TypeScript Programming Projects

        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