[Gambas-user] traslate grep expresion to detect COMMENT in line sql

PICCORO McKAY Lenz mckaygerhard at ...626...
Fri Jul 28 21:04:39 CEST 2017


umm RegExp.Replace are only since 3.5 .. searching for alternatives, due i
have for now Debian wheeze and the gamgas (with supoport by vendor) are 3.1

any ideas?

Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com

2017-07-28 13:51 GMT-04:00 Fernando Cabral <fernandojosecabral at ...626...>:

> 2017-07-28 12:50 GMT-03:00 PICCORO McKAY Lenz <mckaygerhard at ...626...>:
>
> > wow! i must made a string search procedure until "comment" was find.. !
> >
> > i think that but i also think that a reg expresion must be better with
> pcre
> > component!
> >
>
> My suggestion it to be used with pcre componte. I only gave you the search
> and replace regular expression. Something like
>
> NewLine  = RegExp.Replace(OldLIne,
> "^(.*?) COMMENT +?(".*?")(,.*?)", "&1 \*&2*/&3", RegExp.UTF8)
>
> But, since I presume you'll be using it several times, then it will be more
> efficiente if you compile it first.
>
> - fernando
>
> Lenz McKAY Gerardo (PICCORO)
> > http://qgqlochekone.blogspot.com
> >
> > 2017-07-28 11:34 GMT-04:00 Fernando Cabral <fernandojosecabral at ...626...
> >:
> >
> > > 2017-07-28 11:57 GMT-03:00 PICCORO McKAY Lenz <mckaygerhard at ...626...
> >:
> > >
> > > >
> > > > my target objetive it parse a text/line like this:
> > > >
> > > >  fiel1 TEXT COMMENT "coment fiel1" , field2 TEXT, fiel3 TEXT
> > > >  fiel4 NUMBER(10,2), fiel5 TEXT COMMENT "pepepeep",
> > > >  fiel6 TEXT
> > > >
> > > > into this:
> > > >
> > > >  fiel1 TEXT /* coment fiel1*/ , field2 TEXT, fiel3 TEXT
> > > >  fiel4 NUMBER(10,2), fiel5 TEXT /*pepepeep*/,
> > > >  fiel6 TEXT
> > > >
> > >
> > > Let me see if I have understood this well enough:
> > > a) find the word " COMMENT " (whitespace before and after), followed by
> > > whatever till you find a "," (comma)
> > > b) Delede " COMMENT " and put "whatever" between "/*" and "*/"
> > > c) Leave untouched whatever is after the first "," (comma) including
> the
> > > comma itself.
> > >
> > > Is that right? If it is, you should start by compiling this regular
> > > expression:
> > >
> > > "^(.*?) COMMENT +?(".*?")(,.*?)"
> > >
> > > And the replace by: "&1 \*&2*/&3"  (scape as needed) and this should
> > work.
> > >
> > > what it does:
> > > a) from the start of the line, find whatever exists until the
> expression
> > "
> > > COMMENT " -- which should not be included.
> > > b) Save that firt part into the buffer number 1
> > > c) Skip til after the last white space after " COMMENT " - throw that
> > away
> > > d) save the next portion between double quotes and save into buffer
> > number
> > > 2
> > > e) Save next portion into buffer number 3
> > >
> > > Put back the contents from buffer 1, add "\*", put back the contents of
> > > buffer 2, add "*/" and then put back the contents of buffer number 3.
> > >
> > > You may have to tinker around a little, but I think this contains the
> > basic
> > > ideia.
> > >
> > > - fernando
> > >
> > >
> > >
> > >
> > > Lenz McKAY Gerardo (PICCORO)
> > >
> > > > http://qgqlochekone.blogspot.com
> > > > ------------------------------------------------------------
> > > > ------------------
> > > > Check out the vibrant tech community on one of the world's most
> > > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > > _______________________________________________
> > > > Gambas-user mailing list
> > > > Gambas-user at lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >
> > >
> > >
> > >
> > > --
> > > Fernando Cabral
> > > Blogue: http://fernandocabral.org
> > > Twitter: http://twitter.com/fjcabral
> > > e-mail: fernandojosecabral at ...626...
> > > Facebook: f at ...3654...
> > > Telegram: +55 (37) 99988-8868
> > > Wickr ID: fernandocabral
> > > WhatsApp: +55 (37) 99988-8868
> > > Skype:  fernandojosecabral
> > > Telefone fixo: +55 (37) 3521-2183
> > > Telefone celular: +55 (37) 99988-8868
> > >
> > > Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
> > > nenhum político ou cientista poderá se gabar de nada.
> > > ------------------------------------------------------------
> > > ------------------
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > _______________________________________________
> > > Gambas-user mailing list
> > > Gambas-user at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
>
>
>
> --
> Fernando Cabral
> Blogue: http://fernandocabral.org
> Twitter: http://twitter.com/fjcabral
> e-mail: fernandojosecabral at ...626...
> Facebook: f at ...3654...
> Telegram: +55 (37) 99988-8868
> Wickr ID: fernandocabral
> WhatsApp: +55 (37) 99988-8868
> Skype:  fernandojosecabral
> Telefone fixo: +55 (37) 3521-2183
> Telefone celular: +55 (37) 99988-8868
>
> Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
> nenhum político ou cientista poderá se gabar de nada.
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list