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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:57:11+00:00 2026-05-24T10:57:11+00:00

I wanna do something that would work much like this shortcode in stackexchange. So

  • 0

I wanna do something that would work much like this shortcode in stackexchange.

So basically I want to wrap text with distinct markers and .wrap() them in spans with specific classes accordingly… while also removing the markers that once existed.

I found this Find Text Between 2 Quotes with jQuery but it gives little help as i could only make it work as it was.

This explains a little further: http://jsfiddle.net/ALfsT/3/

I have no idea where to go with 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-05-24T10:57:12+00:00Added an answer on May 24, 2026 at 10:57 am

    Thanks @Guffa for the help here

    http://jsfiddle.net/mplungjan/AkCED/

    var res = {
        boldIt:/\*\*(.*?)\*\*/g,
        underlineIt:/\_\_(.*?)\_\_/g
    }
    var txt = $( "#texts" ).html();
    $.each(res, function(type, re) {
      txt = txt.replace( re, '<span class="'+type+'" >$1</span>' );
    });
    $( "#texts" ).html(txt);
    

    update:

    now we need to code stuff like this http://jsfiddle.net/mplungjan/bhTAM/

    You changed to class=texts I changed it back to id=texts and it worked better

    var res = {
        boldIt:{re:/\*\*(.*?)\*\*/g,tag:"span"},
        underlineIt:{re:/\_\_(.*?)\_\_/g,tag:"span"},
        italicIt:{re:/\/\/(.*?)\/\//g,tag:"span"},
        titleIt:{re:/\=\=(.*?)\=\=/g,tag:"h1"},
        linkIt:{re:/\#\#(.*?)\:(.*?)\#\#/g, tag:"a"},
        imageIt:{re:/\"\"(.*?)\:(.*?)\"\"/g, tag:"img"}
    }
    var s = $("#texts").html();    
    $.each(res, function(type, obj) {
      if(s) s = s.replace(obj.re,'<'+obj.tag+' class="'+type+'" >$1</'+obj.tag+'>');
    });
    $("#texts").html(s);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey i wanna do something like this: i=2; _root.(process + i)._x = var_Process_Pos_x; how
So i wanna do something like this in php. If i have a year
I wanna create queue management system (for bank, hostpital...) Something like that There will
I don't know if this is possible but it sounds like something that should
Something that really would like to know but never found out are shortcuts in
I wanna do something like the safari app when fill a form, so when
I wanna rewrite links like index.php?page=entry&id=15&action=edit to entry/15/edit . This is how my .htaccess
I wanna implement something like in facebook: after left click on photo, it is
Im trying to do something like this (This is MySQL format) SELECT q.question_id, q.question,
Should sound weird, but this is just for my hobby. I would want a

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.