in reply to book vs. web for Perl Regex study?
How can you study Java and not encounter regular expressions??? Maybe it's time to take the lesson again:P
I was delighted when it was added, though I think it's fair to say that compared to Perl the Java way of working with it is (a bit...) cumbersome. Take for example the following snippet.
import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class BLA { public static final String BLA_PATTERN = "\"([^\"]+?)\",?|([^,]+),?| +,"; private static Pattern blaRE; public BLA() { blaRE = Pattern.compile(BLA_PATTERN); } public List<String> parse(String line) { List<String> list = new ArrayList<String>(); Matcher m = blaRE.matcher(line); while (m.find()) { // do stuff } return list; } }
In Perl this would be just one line:)
|
|---|