#1
  1. 300lb Bench!
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Aug 2001
    Location
    New York
    Posts
    2,350
    Rep Power
    62

    Regular Expressions in java


    Alright, guys I haven't used Java in over three years and I need some help. I've been assinged the task of creating a java servlet with upload capabilities. Now I've already searched the site and I see a number of solutions for uploading. My problem is, after I get this file, I need to do a lot of adjustments to it. This would be super easy in perl, but we're trying not to introduce too many technologies to solve the problem. Here are my questions.

    1. Does Java have regular expressions? (although the 1000+ page tome I have doesn't mention it, I'd like to know for sure).
    2. If Java doesn't have regular expressions, can the perl interpreter be embedded into java so that I can access perl's functionality (I know that this can be done in C).
    3. If no. 2 isn't possible, can java kick off a system command (which in this case could be a perl script). Again, the tome I have doesn't mention a java class to handle system commands.

    Obviously I'd like choice number one to be available to me because I don't want the overhead of loading the perl script into memory every time. Any help would be greatly appreciated. Thanks in advance.
  2. #2
  3. 11
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jul 2001
    Location
    Lynn, MA
    Posts
    4,635
    Rep Power
    83
    google is your friend. Next time start there.

    see

    http://jakarta.apache.org/regexp/

    which was result 5 when I searched for "java regular expressions"

    So, no, java doesn't come with regular expressions by default.
  4. #3
  5. 300lb Bench!
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Aug 2001
    Location
    New York
    Posts
    2,350
    Rep Power
    62
    Thanks for the tip!
  6. #4
  7. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Posts
    7
    Rep Power
    0
    Isn't regular exp. built into 1.4?
  8. #5
  9. 300lb Bench!
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Aug 2001
    Location
    New York
    Posts
    2,350
    Rep Power
    62
    Actually, it looks like they do. From what I see, however (and I haven't really looked at it to much, so I'm probably wrong), it looks like the reg ex package created by apache is more extensive. Anyway, the good thing is that there are solutions out there. Thanks, guys.
  10. #6
  11. 300lb Bench!
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Aug 2001
    Location
    New York
    Posts
    2,350
    Rep Power
    62
    As usual, I'm completely wrong. At least I'm consistent at something. Although the 1.4 syntax is different to the reg ex package created by apache, it looks to be just as robust. I'll say no more about this!
  12. #7
  13. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Posts
    7
    Rep Power
    0
    I'm glad you checked this out. I'm going to be building a log parser in Java, and needed a Regex package. I was originally going to use Apache's solution, but since this is built right in and I'm running 1.4, I'll use this instead.
  14. #8
  15. Golden Member =p
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    Final Frontier
    Posts
    9
    Rep Power
    0
    i find http://www.cacas.org/java/gnu/regexp a really nice alternative to both the jdk and apache regex packages.
  16. #9
  17. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    5
    Rep Power
    0

    Apache ORO


    Java 1.4 does add regular expressions. There are actually two jakarta regex packages. regexp like two posters mentioned and also ORO (http://jakarta.apache.org/oro/) ORO is more complete than regexp and I think is more like Perl's pattern matching.
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    0
    Rep Power
    0
    Originally posted by Hero Zzyzzx
    google is your friend. Next time start there.

    see

    http://jakarta.apache.org/regexp/

    which was result 5 when I searched for "java regular expressions"

    So, no, java doesn't come with regular expressions by default.
    good

IMN logo majestic logo threadwatch logo seochat tools logo