High-Seas and Java Regex

merlyn on 2002-09-12T17:59:22

I miss having the wireless on-board the Cruise Ship. On the other hand, I had ample spare time to write a 90-minute "Regex in Java" talk that I'm presenting this afternoon.

Turns out java.util.regex in Java 1.4 is a very close cousin to Perl's regex engine, so a lot of my brain was already wired correctly. However, it'll be fun talking about how you have to put four backslashes in a row to get a single backslash on a s/// equivalent. Whoa.

Thank goodness for the timing of MRE2, as I lifted most of what I know about Java regex directly from there. My autographed copy obtained at OSCON is now dog-eared.


Triply escaped backslashes

vsergu on 2002-09-12T20:42:50

I wrote something like this line a few months back:

$sql .= " AND path LIKE '\\\\\\\\\\\\\\\\servername\\\\\\\\share\\\\\\\\%'";

Scary, I know, but it works. I suppose there are various ways of getting rid of at least one level of escaping. Best of course would be to use forward slashes in the database in the first place.