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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:49:03+00:00 2026-06-14T07:49:03+00:00

I am attempting to use regexes in jQuery, and I am running into some

  • 0

I am attempting to use regexes in jQuery, and I am running into some problems. This is the string that I am operating on:

NSLog(@"It works!");

I want the regex to select everything between the @” and the “, inclusive. This regex works just fine in Reggy, but when put in my JavaScript, does not work:

@".*"

My jQuery code is as follows in this section (is single-quotes the issue, perhaps?):

var regex='@".*"';
$(".syntaxhighlight").highlight(regex,'string');

I know the issue is not the highlight() function, because this works just fine:

$(".syntaxhighlight").highlight('nil','string');

So, how do I get this regex working properly?

  • 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-14T07:49:05+00:00Added an answer on June 14, 2026 at 7:49 am

    The highlight() feature uses String.indexOf() internally, which doesn’t support regular expression objects.

    However, it can be rewritten like so:

    $.fn.extend({
     highlight: function(pat) {
      function innerHighlight(node, pat) {
       var skip = 0;
       if (node.nodeType == 3) {
        var res;
    
        while (res = pat.exec(node.data)) {
         var spannode = document.createElement('span');
         spannode.className = 'highlight';
         var middlebit = node.splitText(res.index);
         var endbit = middlebit.splitText(res[0].length);
         var middleclone = middlebit.cloneNode(true);
         spannode.appendChild(middleclone);
         middlebit.parentNode.replaceChild(spannode, middlebit);
         skip = 1;
        }
       }
       else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
        for (var i = 0; i < node.childNodes.length; ++i) {
         i += innerHighlight(node.childNodes[i], pat);
        }
       }
       return skip;
      }
      return this.length && pat ? this.each(function() {
       innerHighlight(this, pat);
      }) : this;
    }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng
Attempting to use the data series from this example no longer passes the JSONLint
In attempting to use std::select1st from <functional> in a VS2008 project I found that
I am attempting to use the AutoComplete plugin for jQuery UI, specifically the multiple
I'm attempting to use the jQuery UI Tabs module, but whenever I attempt to
I am attempting to use AJAX in jQuery to load content to a div,
Attempting to use asp.net mvc's Action Result of File. So it would seem that
I am attempting to use XMLParse against content that is not valid xhtml. In
I am attempting to use an Ant build script to build a project that
I'm attempting to use a 3rd party service that uses OAuth 1.0a and requires

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.