The moose likes Java in General and the fly likes Nesting or subroutines in RegEx Pattern class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Nesting or subroutines in RegEx Pattern class" Watch "Nesting or subroutines in RegEx Pattern class" New topic
Author

Nesting or subroutines in RegEx Pattern class

Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4422
    
    2

I'm writing a small parser for the "Content-Type" line in email and HTTP pages.

I really want to break the one Pattern into two for more rational processing:




What I would like is for the "x-token" in the first pattern refer to the xtokenPattern in the second line. But I can't make this happen. Is it possible? What do I need to do?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16692
    
  19

You can probably just replace the x-token in the first with the second regex in a group... However, if you do that, the greedy nature of the second regex will probably take the rest of the characters. You might also want to change the second regex to be relunctant.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4422
    
    2

Thanks, but my first posting was not exactly what I wanted. I want to have different values for case-sensitive. And my real case is a lot more complex, I simplified it for posting.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nesting or subroutines in RegEx Pattern class
 
Similar Threads
java regular expression
Static method variables
Regex to parse arguments
If only one vowel is entered in the string, then that vowel should be diplayed on console
Regex and startsWith