Jump to content


Photo

regex experts


This topic has been archived. This means that you cannot reply to this topic.
41 replies to this topic

#21 FradettII

FradettII

    PUTTANA SUCCHIA BACINI

  • Membri
  • PipPipPipPipPipPipPip
  • 27613 posts

Posted 04 April 2012 - 16:39

ma se al posto della stringa (LUFTHANSA THREE ZERO TWO NINER)

devi elaborare la stringa

(BRITISH AIRWAYS THREE ZERO TWO NINER)

?

O le linee aeree ti arrivano sempre senza spazi?
"When a long train of abuses and usurpation's presume invariably the same object. Evinces the design to reduce them under absolute despotism. It is their right, it is their duty to throw off such government. And provide new guards for their future security." Thomas Jefferson

#22 toyo

toyo

    sono triste

  • Donatori di sperma
  • PipPipPipPipPipPipPip
  • 44143 posts

Posted 04 April 2012 - 16:43

Da come scrivi però sembra che tu odi la bash e questo non lo perdono :challenge:

Si ma ora qualcuno sa come far eseguire 'sta regex a Qt ?


noi abbiamo usatoe regex su qt, ora sono su aifon ma se dici appena arrivo a casa ti mostro il codice

FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
 

Mai più giorni felici


#23 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 04 April 2012 - 20:11

Tiger, ho scritto che il programma non deve sapere come fare a creare una stringa da una di input.
Troppo facile altrimenti, lo faccio in 3 righe con Qt.

È un po' complesso da spiegare ma sto lavorando su un programma che deve creare delle grammars per l'ASR (auto speech recog).
Ogni grammar può avere dei templates coi quali crea altre grammars e questi templates (secondo me, non mi è stato chiesto) devono essere dinamici. Quindi, per poter rendere il tutto dinamico, devo mettere la regola di creazione della stringa in questione (che è un template) sotto forma di regex visto che la regola viene salvata in una tabella (dinamica, ovviamente :pff: ) nel DB.

Io non vedo alternative al regex visto che devo passare una regola sottoforma di stringa ad un programma C++.
Se qualcuno ha un'alternativa, ben venga.

@Fradetti: good point tnx, domani chiedo.

@toyo: grazie ma ho già chiesto a qt: http://www.qtcentre....7544#post217544
Comunque se sai qualcosa bene, tutto fa brodo.
Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#24 Nex

Nex

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 19500 posts

Posted 04 April 2012 - 20:14

Tralla, domanda: ma sei sicuro che un domani, nel caso tu voglia cambiare lavoro, ti lasceranno andare e non ti faranno sparire in una colonna di un prefabbricato o scioglieranno nell'acido?

Con tutte le cose super-segretissime dell'esercito, areonautica e sarcazzo che segui, ormai sarai sicuramente a conoscenza di nmila informazioni riservate sui sistemi...
Then I went to my pretty rose tree / To tend her by day and by night / But my rose turned away with jealousy / And her thorns were my only delight...

#25 toyo

toyo

    sono triste

  • Donatori di sperma
  • PipPipPipPipPipPipPip
  • 44143 posts

Posted 04 April 2012 - 20:18

ehi trallacoso, mi sono appena accorto che non cosiamo stringhe usando la regex, semplicemente validiamo (o meno) una stringa in base ad una QRegExp settata, usando contains (che a, mentre mia madre succhia cazzi, occhio penso sia di QString)

FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
 

Mai più giorni felici


#26 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 04 April 2012 - 20:18

Figurati, facciamo "semplici" programmi di esercitazione e simulazione.
Di cose super segrete non ne so manco una.
Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#27 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 04 April 2012 - 20:20

ehi trallacoso, mi sono appena accorto che non cosiamo stringhe usando la regex, semplicemente validiamo (o meno) una stringa in base ad una QRegExp settata, usando contains (che a, mentre mia madre succhia cazzi, occhio penso sia di QString)


Ah, quindi regexp.ifMatches() o qualcosa del genere.

Beh, se hai qualche esempio posta, dai.
Altrimenti, se non ci riesco, devo andare su boost e la cosa non mi sconfinfera molto.
Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#28 toyo

toyo

    sono triste

  • Donatori di sperma
  • PipPipPipPipPipPipPip
  • 44143 posts

Posted 04 April 2012 - 20:25

nono, proprio contains di Qstring, c'è quello che accetta una QRegExp: http://qt-project.or...html#contains-7

FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
 

Mai più giorni felici


#29 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 04 April 2012 - 20:26

Ah ok, useless for me.
Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#30 _TeRmInEt_

_TeRmInEt_

    Il salvatore del forum

  • Amministratori
  • 3925 posts

Posted 04 April 2012 - 23:44

Io avrei usato preg_replace :asd:

The thing I hate the most is to trample on other people’s good will.


#31 gugoXX

gugoXX

    Schiavo

  • Membri
  • PipPipPipPipPipPip
  • 5440 posts

Posted 05 April 2012 - 00:07

Dai, gioco anche io

string input =

			    "DLH3029 (LUFTHANSA THREE ZERO TWO NINER)" + Environment.NewLine +

			    "Uellalla uellssl (BRITISH AIRWAYS THREE ZERO TWO NINER)";



		    var output = Regex.Replace(input, @".*((w+(sw+)*)s(w+)s(w+)s(w+)s(w+))", "'$1' '$3' '$4' '$5' '$6'");



		    Console.WriteLine("Input:");

		    Console.WriteLine(input);

		    Console.WriteLine();

		    Console.WriteLine("Output:");

		    Console.WriteLine(output);

		    Console.ReadKey();

Input:
DLH3029 (LUFTHANSA THREE ZERO TWO NINER)
Uellalla uellssl (BRITISH AIRWAYS THREE ZERO TWO NINER)

Output:
'LUFTHANSA' 'THREE' 'ZERO' 'TWO' 'NINER'
'BRITISH AIRWAYS' 'THREE' 'ZERO' 'TWO' 'NINER'


L'unico effetto positivo del comunismo e' quello di far produrre doppio a Civilization

The above post is my PERSONAL OPINION and DOES NOT REPRESENT the official position of any company or entity, and does not derive either from official or internal data of any company I am dealing with.

#32 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 05 April 2012 - 07:36

A Qt ho chiesto come usare la QRegExp solo per la prima parte della regex, quella che trasforma:

"DLH3029 (LUFTHANSA THREE ZERO TWO NINER)"

in:

'LUFTHANSA THREE ZERO TWO NINER'


Qt mi ha risposto:

s/[^(]*(\([^)]*\)).*/'\1'/ are two "commands". One for searching and one for replacing. For Qt you have to split them.



'ndo la splitto ? :look:

Dove inizia il "replace" ?
Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#33 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 05 April 2012 - 07:38

gugo, la stringa è:
"KEY (VAL1 VAL2 VAL3 ... VALn)"
Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#34 gugoXX

gugoXX

    Schiavo

  • Membri
  • PipPipPipPipPipPip
  • 5440 posts

Posted 05 April 2012 - 08:20

E allora mi sa che il "British Airways" ce lo perdiamo.
L'unico effetto positivo del comunismo e' quello di far produrre doppio a Civilization

The above post is my PERSONAL OPINION and DOES NOT REPRESENT the official position of any company or entity, and does not derive either from official or internal data of any company I am dealing with.

#35 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 05 April 2012 - 08:34

No, il "BRITISH AIRWAYS" diventa 'BRITISH' 'AIRWAYS' che è quello che deve dire l'operatore e l'ASR comprendere.

edit: va beh, comprendere :asd: diciamo validare

Edited by trallallero, 05 April 2012 - 08:35.

Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#36 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 05 April 2012 - 08:35

Comunque si fotta Qt, sto facendo in boost.
Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#37 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 05 April 2012 - 09:01

Che coglione! :mother:

Anziché regex che mi sta facendo venire una verticosi testicolare, faccio una funzione sql che crea una stringa per ogni template passato.
Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#38 TigerShark

TigerShark

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16685 posts

Posted 05 April 2012 - 09:08

Mah..ancora mi sfugge il perché di tutto ciò se hai detto che non ti è stato esplicitamente richiesto...
Io sarei andato di KISS e YAGNI e poi in caso fosse servita qualche modifica in futuro si vedeva..
I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past I will turn the inner eye to see its path. Where the fear has gone there will be nothing. Only I will remain.

#39 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 05 April 2012 - 09:25

Tempo fa mi è stato anche detto di fare una GUI per un progetto: "falla fissa tanto non ci sarà nulla da cambiare in futuro".
L'ho fatta invece tanto dinamica da chiamarla DGC (Dynamic Gui Creator) introducendo per primo nel mio gruppo i plugins.
Adesso quasi tutte le GUIs che usiamo vengono fatte col mio DGC ;)

E comunque è KISS perché passo un id ed una stringa ad una funzione psql che mi restituisce un'altra stringa.
Se in futuro vogliamo aggiungere (e succederà) altri templates, basterà aggiornare la funzione psql senza dover ricompilare.
Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#40 TigerShark

TigerShark

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16685 posts

Posted 05 April 2012 - 09:54

ah gia', dimenticavo che voi non potete fare class-loading dinamico. :pua:
I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past I will turn the inner eye to see its path. Where the fear has gone there will be nothing. Only I will remain.