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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:21:32+00:00 2026-06-08T23:21:32+00:00

Hi stackoverflow ‘ers. I want to create like a text parser with jQuery. What

  • 0

Hi stackoverflow‘ers. I want to create like a text parser with jQuery. What I want is to create a function, in order to pass a string and convert it.

Let’s say I have a div with the following HTML code:

<div class="item">
    [styled] //The "command" in order to process. If not, return false;
        [code1]Text1[/code1]
        Text2
        [code3]Text3[/code3]
    [/styled]
</div>  

I want to do this in jQuery

$(".item").html(my_decode($(this).html());

And change ‘div.item’ innerHTML to

<div class="item">
    <span class="styled">
        <span class="code1">Text1</span>
        Text2
        <span class="code3">Text3</span>
    </span>
</div>

As you can see, it checks for [styled], and if it exists, creates a <span> with class “styled”. And each other [], create a `<span> with the class of the content.

[a]1[/a] [2]a[/2] => <span class="a">1</span> <span class="2">a</span>

Thanks!

  • 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-08T23:21:34+00:00Added an answer on June 8, 2026 at 11:21 pm

    I’d suggest you look at an open-source parser such as Jison, and get ideas from it. Then you can create your own solution and learn a lot from the experience.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi stackoverflow jquery experts, I've got a problem on my ajaxStart function and ajaxComplete
StackOverflow'ers I am new to jQuery but I am currently using the BXslider Plug
StackOverflow'ers, I realize the new @mentions is a very new feature to facebook, but
In stackoverflow, when we hover on a user's reputation we see a text. I
Hi Stackoverflow people, I am implementing the MarkerCluster function for google map markers. I
Stackoverflow, I am working with the Tabs via the Jquery Tools: Tabs system and
Hi stackoverflow team i have a problem in converting base64 string to bitmap in
StackOverflow has yet to fail me, so don't let me down this time! I
Dear stackoverflow members, I have a small problem, I want to replace some characters
https://stackoverflow.com/a/5524120/462608 If you want to call functions recursively, which lock the same mutex, then

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.