Re: Ruby , regexp et parsing
[ Nouvelle discussion
| Répondre au groupe
|
fr.comp.lang.ruby ]
Sujet: Re: Ruby , regexp et parsing
De: john....@anonymous.org (mosfet)
Groupes: fr.comp.lang.ruby
Organisation: Guest of ProXad - France
Date: 04. Feb 2008, 14:53:12
References: 1
|
mosfet a écrit :
> Salut,
>
> Je suis un debutant complet en ruby et j'aimerais l'utiliser afin
> d'extraire des données d'un fichier.
>
> En gros j'ai un fichier texte qui contient des definitions COM
>
> #define PR_ORIGINAL_ENTRYID PROP_TAG( PT_BINARY,
> 0x3A12)
> #define PR_ORIGINAL_DISPLAY_NAME PROP_TAG(
> PT_TSTRING, 0x3A13)
>
>
> et j'aimerais ouvrir ce fichier pour construire un tableau de propriétés :
>
>
> typedef struct mapiProp_s
> {
> ULONG ulPropId;
> ULONG ulPropType;
> }mapiProp_t;
>
> mapiProp_t mapiPropArray[] =
> {
> { PR_ORIGINAL_ENTRYID, "PR_ORIGINAL_ENTRYID", PT_BINARY },
> { PR_ORIGINAL_DISPLAY_NAME, "PR_ORIGINAL_DISPLAY_NAME", PT_TSTRING },
> };
>
>
> Si quelqu'un pouvait me donner quelques pistes.
>
>
>
>
> Merci
Pour le moment j'arrive a ca :
File.open('C:/mapitags.h', 'r') do |filein|
File.open('C:/mapitags_Props.h', 'w') do |fileout|
regex = Regexp.new('PR_ \"(w+)\"')
while line = filein.gets
match = regex.match(line)
if match
puts match[1]
else
puts "Skip this line"
end
end
end
end
Mais c'est pour la regexp ou j'ai du mal ...

|
 cette fonctionnalité est reservée aux membres ayant une session active !
|