On Thu, 28 Mar 2013, Beno?t Minisini wrote: > Le 28/03/2013 07:47, Bruce a ?crit : > > On Thu, 2013-03-28 at 17:05 +1030, Bruce wrote: > >> Hi, > >> > >> I am trying to parse a text file that contains key,value pairs like: > >> Name=Malarky > >> Size=10 > >> BackImage[N]=sometext > >> FrontImage[S]=sometext > >> etc > >> using a construct like > >> For idx = 0 to sourcearray.max > >> Select Upper(Split(SourceArray[idx],"+")[0]) > >> Case "NAME" > >> blah blah > >> Case "SIZE" > >> blah blah > >> Case Like "BACKIMAGE[*]" > >> blah blah > >> Case Like "FRONTIMAGE[*]" > >> blah blah > >> End Select > >> Next > >> > >> This fails because Case Like "BACKIMAGE[*]" is being interpreted as a > >> regular expression where I need to escape the regexp "[]" meaning. > >> > >> Trying to use escapes like > >> Case Like "BACKIMAGE\[*\]" > >> fails as \[ is an unknown escape sequence. > >> > >> Any clues? > >> > >> tia > >> Bruce > >> > > > > Sorry, I have over simplified that. I also need to discern lines like > > BACKIMAGE[*] > > from lines like > > BACKIMAGE[*][*] > > so > > Like "BACKIMAGE*" > > wont work. > > > > B > > > > Case "BACKIMAGE[[]*]" > Case "BACKIMAGE[[]*][[]*]" > > Is that what you want? > > Escaping '[' character in regular expression is done by using "[[]" or > "\\[". (see the documentation of LIKE). >
This expression (the first one of yours) would match "BACKIMAGE[", "BACKIMAGE*" or "BACKIMAGE]" but not "BACKIMAGE[*]" Using the []-LIKE notation, the correct expression would be "BACKIMAGE[[][*][]]" but I'd prefer the "\\" style for readability in this case. CMIIW. Regards, Tobi ------------------------------------------------------------------------------ Own the Future-Intel® Level Up Game Demo Contest 2013 Rise to greatness in Intel's independent game demo contest. Compete for recognition, cash, and the chance to get your game on Steam. $5K grand prize plus 10 genre and skill prizes. Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user