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

  • Home
  • SEARCH
  • 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 3218238
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:30:16+00:00 2026-05-17T15:30:16+00:00

I have problem need to solved with Regex If i am using Firefox or

  • 0

I have problem need to solved with Regex

If i am using Firefox or IE8 javascript will generate this code which is what I really want.

<div style="visibility: hidden;" id="wizardId1">1001</div><div style="visibility: hidden;" id="wizardId2">1002</div>

However with IE7 it will generate diferently to be

<DIV id=wizardId1 style="VISIBILITY: hidden;">1001</DIV><DIV id=wizardId2 style="VISIBILITY: hidden;" >1002</DIV>

which is the id for the div is placed before style parameter.

In my java program, i have regex only to support the first one (Firefox & IE8)
the regex is

<(?:DIV|div)\s+style=(?:["\'])*(?:[\w\d:; ]+)*(?:["\'])*\s+id=(?:["\'])*([\w\d]+)(?:["\'])*>([\w\d]+)</(?:DIV|div)>

Because the IE7 placed the id before the style, so i could get the result that i want like this

Result should be appeared

Match 1: <div style="visibility: hidden;" id="wizardId1">1001</div>
    Subgroups:
    1: wizardId1
    2: 1001
Match 2: <div style="visibility: hidden;" id="wizardId2">1002</div>
    Subgroups:
    1: wizardId2
    2: 1002

I tried to use this regex (to take out the style from regex) but the result only return the last id.

<(?:DIV|div).*\s+id=(?:["\'])*([\w\d]+)(?:["\'])*>([\w\d]+)</(?:DIV|div)>

result not wanted

Match 1: <div style="visibility: hidden;" id="wizardId1">1001</div><div style="visibility: hidden;" id="wizardId2">1002</div>
    Subgroups:
    1: wizardId2
    2: 1002

Question

How can i produce the same result using regex as the first result by not considering the ( style=”visibility: hidden;” ) ?
(Not to use .* and not to add extra group)

Thanks for helping me.

  • 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-17T15:30:17+00:00Added an answer on May 17, 2026 at 3:30 pm

    Previously, the .* was matching everything from the end of the first <div through and including the second <div.

    You can try using a minimal match.

    So

    <(?:DIV|div).*?\s+id=(?:["\'])*([\w\d]+)(?:["\'])*[^>]*>([\w\d]+)</(?:DIV|div)>
    

    instead of

    <(?:DIV|div).*\s+id=(?:["\'])*([\w\d]+)(?:["\'])*[^>]*>([\w\d]+)</(?:DIV|div)>
    

    Note the ? after the .* means match as few as possible.

    I would recommend against trying to parse HTML with regexs though.
    Maybe you could try a SAX style parser like makeSaxParser in http://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja/plugin/html-sanitizer.js

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

Sidebar

Related Questions

I need some ideas on how I can best solve this problem. I have
I have this idea for a free backup application. The largest problem I need
Problem I have timestamped data, which I need to search based on the timestamp
I have a problem where I always need to give simple access to my
I have a problem. I need to host grid with controls in ScrollViewer to
I have a problem with reflection. I need to find the type that instantiates
I have a problem: imagine I have a plugin-based system. I need some kind
i have a problem, i'm working on a gallery php script and need help,
Problem: I have to support users who need to edit web pages. Some of
i have very simple problem. I need to create model, that represent element of

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.