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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:08:50+00:00 2026-06-06T16:08:50+00:00

I have combined MathJax and Markdown markup and therefore I need to replace all

  • 0

I have combined MathJax and Markdown markup and therefore I need to replace all $$ with <span>$$</span> so that Markdown don’t render $$_^… signs from MathJax. Also all \[ \] must be replaced with <div>\[ \]</div>.

I found similar question but it’s not exactly what I need. I need to convert this

This is $some$ math \[equation\] which I $like$.

to this

This is <span>$some$</span> math <div>\[equation\]</div> which I <span>$like$</span>.

Probably what I need to to is just in regex

text = text.replace(/\$.*?\$/g, "meow");

somehow include and $$ signs (or \[ \]) and just with $1 embed the text inside <span>$$1$</span> and adapt to PHP.

  • 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-06T16:08:51+00:00Added an answer on June 6, 2026 at 4:08 pm

    You need to do it in two steps because the replacement texts are different.

    First, replace the $..$:

    $text = preg_replace('/\$.*?\$/', '<span>\0</span>', $text);
    

    Then, replace the \[...\]:

    $text = preg_replace('/\\\\\[.*?\\\\\]/', '<div>\0</div>', $text);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three arrays that need to be combined in one three-dimension array. The
We have 15 audit trail tables that need to be combined to look for
i'm using Moscow ML combined with CGI. I have a site that calculates simple
I have a page that needs to combine data from four different webrequests into
I have combined two arrays using array_merge, and now need to sort them alphabetically.
UPDATE I have combined various answers from here into a 'definitive' answer on a
Hi to all, Is there any class which have combined functionality of ScaleGestureDetector and
Q: If I have a composite key combined from 4 fields for example, can
I have combined RIA Services with Entity Framework using POCO's. It's all worked wonderfully
I'm using some components from twitter bootstrap css and have combined into a custom

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.