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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:15:28+00:00 2026-05-27T04:15:28+00:00

see – > i have the following text in a variable var s =

  • 0

see – > i have the following text in a variable

var s = 

    "<html>
  <head>
    <style type="text/css" >     
      body{
 background:url(/a.png);
          }
    </style>
    <script src="2.js"></script>
    <script src="1.js"></script>
  </head>
  <body >
   {BODYCONTENT}
  </body>


</html>";

Now i want to append some data immediately after closing of <style> tag’s > .

Ex :

var mydata = "/n h1{a:b}/n";

So i want

<style>/n h1{a:b}/n

it is very easy if there is no other attribute in style tag,but sometime there may be some other attributes like type ,id

ex :

<style type="text/css" id="default_css_scope">
content
</style>

so that i cant use like this s.replace("<style>","<style>".mydata);

How can i do this with Regular Expression ?

  • 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-27T04:15:29+00:00Added an answer on May 27, 2026 at 4:15 am

    Caveat: I do not recommend using regular expressions to work extensively with HTML.

    But you might get away with it in this specific case:

    str = str.replace(/<style[^>]*>/, function(m) {
        return m + mydata;
    });
    

    Live example

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

Sidebar

Related Questions

See my code <html> <body> <script type=text/javascript> var str=Visit Microsoft!; document.write( str = str.replace(,'ss'));
see this link...: Exemple on this site i have this code <body> <div id=geral>
See the test case below: $val = floatval(336.00); $result = 300*1.12; header(content-type: text/plain); echo
See http://pilot.whatpub.org/Guide/002000/Pub002687.htm and have a look at the source. The text in the description
see in one code i have written void my_function() { INT32 i; /* Variable
See code: var file1 = 50.xsl; var file2 = 30.doc; getFileExtension(file1); //returns xsl getFileExtension(file2);
See here: http://code.google.com/p/ie7-js/ Does anyone have any experience or remarks about this javascript? Is
See: http://jsbin.com/ebudec/edit#javascript,html It seems strange but I think jsBin doesn't recognize the jQuery document
SEE EDIT UPDATES BELOW. Original question has been modified! I have a working window
See,I have this code: template<typename T=int>struct color { T red, green, blue; color(T r,

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.