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

  • Home
  • SEARCH
  • 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 8696153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:12:47+00:00 2026-06-13T01:12:47+00:00

I have a javascript-string which contains semicolons (some of them are escaped). My problem

  • 0

I have a javascript-string which contains semicolons (some of them are escaped).

My problem is, how do I split this string on all unescaped semicolons and leave the escaped ones

var example = "abc;def;ghi\;jk"

This should get:

example[0] = "abc";
example[1] = "def";
example[2] = "ghi\;jk";

I only found a PHP-regex, which is not working in javascript 🙁

'/(?<!\\\);/'

any ideas how to do this?

  • 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-13T01:12:48+00:00Added an answer on June 13, 2026 at 1:12 am

    JavaScript has no negative look-behind (which would make this problem simple), so we can emulate it by reversing the string and using negative look-ahead!

    function splitByUnescapedSemicolons(s) {
      var rev = s.split('').reverse().join('');
      return rev.split(/;(?=[^\\])/g).reverse().map(function(x) {
        return x.split('').reverse().join('');
      });
    }
    
    splitByUnescapedSemicolons("abc;def;ghi\;jk"); // => ["abc", "def", "ghi\;jk"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Javascript: Unicode string split by chars I have a javascript string which
In javascript, I have a string which contains numbers, and I want to increment
i have a javascript variable which contains a string with new lines and spaces
I have a javascript string which have a leading dot. I want to remove
I have one method in my managed bean which returns javascript as a string.
Hi I have a problem with a javascript string var foo = \<a href=javascript(foo('a','b'))>test</a>\
I have a JavaScript app that produces a string. I want to transfer this
I have a string which contains HTML text. I need to escape just the
Suppose I have a string which contains an HTML file. How do I get
I have a variable which contains the following string placeholder = <strong>Total Damage:</strong> $70,000.00

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.