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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:57:45+00:00 2026-05-28T22:57:45+00:00

I am trying to replace all h2 tags containing the class title with h1:

  • 0

I am trying to replace all h2 tags containing the class “title” with h1:

<h2 class="title">Things</h2>

I’m using the Multi-File search in TextWranger with this:

<h2 class="title">[^>]*</h2>

I’m able to find everything, but when I hit replace, it replaces my titles with the grep crap.

BEFORE: <h2 class="title">Things</h2>
AFTER:    <h1 class="title">[^>]*</h1>

My problem is that the search not only replaces my tags but also replaces my content with [^>]*. I also tried this in Aptana and the same thing happened. I would appreciate some insight.

  • 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-28T22:57:46+00:00Added an answer on May 28, 2026 at 10:57 pm

    It looks like you’re converting <h2 class="title"> to h1? You have to use a backreference in your “replace”:

    Search: <h2 class="title">([^>]*)</h2>

    Replace: <h1 class="title">\1</h1> (aside- if it’s a h1 do you still want to preserve the ‘class=”title”‘?)

    Note the brackets in the search regex, which save what’s inside them.

    Then you use \1 to pull them back out in the replace text (\1 for the first set of brackets, \2 for the second, … )

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

Sidebar

Related Questions

I'm trying to replace all ul tags with a level0 class, something like this:
I'm trying to replace all tags with tags using DOMDocument in PHP and almost
I am trying to replace all £ symbols in a HTML file with &pound;
I'm trying to replace text with an image in all of my h3 tags.
I'm trying to replace all periods with the degree symbol. Using the each method
I'm trying to select some text using regular expressions leaving all img tags intact.
Goal: Using jQuery, I'm trying to replace all the occurrences of: <code> ... </code>
As the title reads, I'm trying to replace all non-alpha characters and replace all
I am trying to remove this div <div id=myid class=myclass>other_tags_here</div> I am using preg_replace
I am trying to replace all numbers except for prices (numbers starting with $)

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.