On Sonntag, 30. Dezember 2007, Thomas Bleher wrote: > * Markus Krötzsch <[EMAIL PROTECTED]> [2007-12-30 22:10]: > > OK, my conclusion now was to support the following syntax: > > > > [[property% *subs?r*]] > > > > where ? and * represent _ and % in SQL. > > I think this is fine generally, but now you cannot query for a literal * or > ? anymore, AFAIK.
I would not consider this to be a major issue, given that those characters are not too common in typical application strings, and given the fact that using "?" still queries for "some symbol" in that place -- it seems to be very unlikely that too strings differ only in one position where the query string has a "?". So in most cases it will have the same hits anyway (yes, there are some cases that could be problematic [1] ;). Anyway, I will leave this issue at rest until any user actually complains about this limitation. Regards, Markus [1] http://de.wikipedia.org/wiki/Die_drei_%3F%3F%3F > > Not a huge deal, but before, "a_b" searched for "a, followed by any char, > followed by b", while "a\_b" searched for "exactly a_b". > > Properly escaping everything gets messy rather quickly, as \ can also be > escaped to query for a literal \, so you need translations like: > > ? => _ > \? => ? > \\? => \\_ > \\\? => \\? > > The following regular expressions work fine for me, but unfortunately they > are quite ugly: > > $value = str_replace(array('%', '_'), array('\%', '\_'), $value); // escape > % and _ $value = preg_replace('/(?<!\\\\)((?:\\\\\\\\)*)\*/', '$1%', > $value); // if there's an even number of \, change * to % $value = > preg_replace('/(?<!\\\\)((?:\\\\\\\\)*)\?/', '$1_', $value); // ditto for ? > and _ $value = preg_replace('/(?<!\\\\)((?:\\\\\\\\)*)\\\\\*/', '$1*', > $value); // if there's an odd number, * was escaped and should stay as is; > but the last \ is removed $value = > preg_replace('/(?<!\\\\)((?:\\\\\\\\)*)\\\\\?/', '$1?', $value); // ditto > for ? > > I think these should be added to SMW, so all characters can be queried. > > Regards, > Thomas -- Markus Krötzsch Institut AIFB, Universät Karlsruhe (TH), 76128 Karlsruhe phone +49 (0)721 608 7362 fax +49 (0)721 608 5998 [EMAIL PROTECTED] www http://korrekt.org
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel