java.util.regex question
Hello All,
I'm fiddling with the regex package in the Java 1.5 beta release, and trying to wrap my head around it.
So that I can understand it better, I'm trying to create a method that will match key/value pairs for a Properties instance out of a String. The String lacks any carriage returns, by design, and is in the simple form of key1=value1;key2=value2;...;keyN=valueN
The logic of the whole method is not my problem, it is getting a proper regex pattern to match.
I'm trying to use the reluctant matching, as, from what I understand (from briefling reading over a perl book on regexs) that should match the smallest appearance of the given pattern.
My pattern is:
;?+(.+?)=(.+?)
Which, from what I gather should match zero or one ;s, then a key=value pair, but not more. I haven't actually tested it yet (as I have to get to work -- running out of time to play with this), but does that look right?
Comments and improvements would be appreciated.
I'm fiddling with the regex package in the Java 1.5 beta release, and trying to wrap my head around it.
So that I can understand it better, I'm trying to create a method that will match key/value pairs for a Properties instance out of a String. The String lacks any carriage returns, by design, and is in the simple form of key1=value1;key2=value2;...;keyN=valueN
The logic of the whole method is not my problem, it is getting a proper regex pattern to match.
I'm trying to use the reluctant matching, as, from what I understand (from briefling reading over a perl book on regexs) that should match the smallest appearance of the given pattern.
My pattern is:
;?+(.+?)=(.+?)
Which, from what I gather should match zero or one ;s, then a key=value pair, but not more. I haven't actually tested it yet (as I have to get to work -- running out of time to play with this), but does that look right?
Comments and improvements would be appreciated.
