Hi Mike,
> > Would the easiest way to do this be to write a thin class in Jython
> > wrapping the regex API, and compile this with Jythonc? It would seem
> > like that should make a simple interface to the Python Regex code easily
> > accessible from the Java side, anyway.
>
> I didn't answer, because I didn't know <g> but that would be how I would
> try it . . .
Understandable. :-)
> > Or is there a better way to do this?
>
> I used ORO Matcher one to do some pretty significat regex substituion in
> Java. I created a HashTable of regular expression statements matched
> with the string they were supposed to substitute in. I gave my class the
> hashtable and the string and matched it. This may or may not be better,
> depending on what you are trying to accomplish.
>
> It was one of the first non-trivial things I have written in Java, and I
> remember stumbling through it. But if you have some experience with
> Java, than it should be pretty easy.
>
> I may have a copy of it somewhere. If you want to see it, mail me off
> the list.
Ah, yes, I can see where this would be useful. Although, for the tasks
that I normally end up using regex for, it really helps to have named
groups. I seem to frequently end up writing XML description languages
for parsing text using regex and placing the results in a HashMap.
So, I'll end up with something like:
<extractor expression="Name: (.*?) Url= (.*?)\nDescription:(.*)"
value1="name" value2="url" value3="description"/>
That works, but it is more than a bit awkward, considering that the
regex could just as easily have defined names for its own groups. :)
Anyway, thanks for the help. I think that it should be fairly easy to
write a good wrapper for this thing the next time I need this
functionality. :)
----
Jess
|