This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Java in General and the fly likes Imitating Java RegEx API in Java2 v1.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Imitating Java RegEx API in Java2 v1.2" Watch "Imitating Java RegEx API in Java2 v1.2" New topic

Imitating Java RegEx API in Java2 v1.2

Bob Robertson

Joined: May 16, 2004
Posts: 17

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.

David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
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

Joined: May 16, 2004
Posts: 17
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:

I agree. Here's the link:
subject: Imitating Java RegEx API in Java2 v1.2
It's not a secret anymore!