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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:24:02+00:00 2026-05-26T04:24:02+00:00

I’m scrubbing through a large number of XML based files in a JSF project,

  • 0

I’m scrubbing through a large number of XML based files in a JSF project, and would like to find certain components that are missing an ID attribute. For example, let’s say I want to find all of the <h:inputText /> elements that do not have an id-attribute specified.

I’ve tried the following in RAD (Eclipse), but something’s not quite right because I still get some components that do have a valid ID.

<([hf]|ig):(?!output)\w+\s+(?!\bid\b)[^>]*?\s+(?!\bid\b)[^>]*?>

Not sure if my negative-lookahead is correct or not?

The desired result would be that I would find the following (or similar) in any JSP in the project:

<h:inputText value="test" />

… but not:

<h:inputText id="good_id" value="test" />

I’m just using <h:inputText/> as an example. I was trying to be broader than that, but definitely excluding <h:outputText/>.

  • 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-26T04:24:03+00:00Added an answer on May 26, 2026 at 4:24 am

    Disclaimer:

    As others correctly point out, it is best to use a dedicated parser when working with non-regular markup languages such as XML/HTML. There are many ways for a regex solution to fail with either false positives or missed matches.

    That said…

    This particular problem is a one-shot editing problem and the target text (an open tag) is not a nested structure. Although there are ways for the following regex solution to fail, it should still do a pretty good job.

    I don’t know Eclipse’s regex syntax, but if it provides negative lookahead, the following is a regex solution that will match a list of specific target elements which do not have an ID attribute: (First, presented in PHP/PCRE free-spacing mode commented syntax for readability)

    $re_open_tags_with_no_id_attrib = '%
        # Match specific element open tags having no "id" attribute.
        <                    # Literal "<" start of open tag.
        (?:                  # Group of target element names.
          h:inputText        # Either h:inputText element,
        | h:otherTag         # or h:otherTag element,
        | h:anotherTag       # or h:anotherTag element.
        )                    # End group of target element names.
        (?:                  # Zero or more open tag attributes.
          \s+                # Whitespace required before each attribute.
          (?!id\b)           # Assert this attribute not named "id".
          [\w\-.:]+          # Non-"id" attribute name.
          (?:                # Group for optional attribute value.
            \s*=\s*          # Value separated by =, optional ws.
            (?:              # Group of attrib value alternatives.
              "[^"]*"        # Either double quoted value,
            | \'[^\']*\'     # or single quoted value,
            | [\w\-.:]+      # or unquoted value.
            )                # End group of value alternatives.
          )?                 # Attribute value is optional.
        )*                   # Zero or more open tag attributes.
        \s*                  # Optional whitespace before close.
        /?                   # Optional empty tag slash before >.
        >                    # Literal ">" end of open tag.
        %x';
    

    And here is the same regex in bare-bones native format which may be suitable for copy and paste into an Eclipse search box:

    <(?:h:inputText|h:otherTag|h:anotherTag)(?:\s+(?!id\b)[\w\-.:]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[\w\-.:]+))?)*\s*/?>

    Note the group of target element names to be matched at the beginning of this expression. You can add or subtract desired target elements to this ORed list. Note also that this expression is designed to work pretty well for HTML as well as XML (which may have value-less attributes, unquoted attribute values and quoted attribute values containing <> angle brackets).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.