Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Imitating Java RegEx API in Java2 v1.2

 
Bob Robertson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am updating an application that is requiring me to write something that will match on the HTML element names in a JSP.

The goal is to exclude the dynamically generated elements in the result. The elements are built from a loop to present a list on the page. The logic is used to uniquely ID a selected element. The format of the elements are as follows:

elementName_i, where i can be 0-15.

Now, I can't leverage the REGEX API like I was hoping to where I could exclude those elements with a character sequence ending in "_i" where I could use the expression for 0-9. I am working with JDK 1.2.

Can someone recommend a solution that will get me started in the right direction?

I can write something that does String evaluations or something and muddle my way through it, but I would like to see if there is a more clean way to go about it.

Any hints would be appreciated.

br
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can use an LGPL package, check out the GNU Regex Library. I haven't used it, but it's been around for ages, and it works with Java 1.1 and up. There's also an older Java 1.0 version still available.
 
Bob Robertson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the insight, David. On a recommendation from a colleague, this is what was implemented. Please note, I am not totally happy with this resolution:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic