[RESOLU] traitement de chaines de caractères

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : [RESOLU] traitement de chaines de caractères

Re: [RESOLU] traitement de chaines de caractères

par aly91 » 02 déc. 2014, 13:10

Bonjour Nestecha,
Je te remercie encore pour les fonctions que tu m'avais filé. Elle m'arche normalement mais il y'a un petit soucis. Il s'avère que dans mon fichier de texte parfois le mot à chercher "PEC" est écrit comme ça "PE C" avec un blanc et non "PEC". Je voudrais en fait que s'il fasse même traitement que ça soit PE C ou PEC.
Mon idée était de faire un test le mot à rechercher s'il y'a un blanc je le supprime et je le passe en paramètre aux fonctions définies. Mais j'y arrive pas.
Bien cordialement.

Re: traitement de chaines de caractères

par aly91 » 12 nov. 2014, 20:18

<?php

function after ($this, $inthat)
{
    if (!is_bool(strpos($inthat, $this)))
        return substr($inthat, strpos($inthat,$this)+strlen($this));
};

function before ($this, $inthat)
{
    return substr($inthat, 0, strpos($inthat, $this));
};


function between ($this, $that, $inthat)
{
    return before ($that, after($this, $inthat));
};

$sLine = "GRE_JEAN_JAURES;NW/UTRAN BTSEquipment/GRE_JEAN_JAURES Board/723467;10-04-2014 11:14:28;null;processing error;warning;active;softwareProgramError;TRDU/11 SOFTWARE DUMP;TRDU/11 SOFTWARE DUMP Specific Problem:TRDU/11 SOFTWARE DUMP, Cabinet:11, Shelf:10, Slot-position:11, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = GP_TRDU Pmdz :The system was power-cycled. - Cause:1 - RRH F/W:_BI_RE_TE_TR_BAND01_FV_1.2.18 - HwRel:AB04 - PEC:3JR21012AB - SN: GPCSTW1000501913 - MOD:TRDUBAND014C60W - SWver:UNB0814A110 } ;BTS_0002_00064;";

echo 'PEC'.between('PEC','-',$sLine);

$sLineSecond = "CINQ_AVENUES;NW/UTRAN BTSEquipment/CINQ_AVENUES Board/81;10-04-2014 15:47:45;null;processing error;warning;active;softwareProgramError;CCM/81 SOFTWARE DUMP;CCM/81 SOFTWARE DUMP Specific Problem:CCM/81 SOFTWARE DUMP, Cabinet:0, Shelf:0, Slot-position:81, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = Uptime : 52 days 04:05:43.Sequence num: 32.Thread name : tCpManager.Thread ID : 0x36ddb4b0.Error number: 0.Signal : 11.State and Misc Registers:. TRAP : 00000300. MSR : 0202d200. DAR : 00000096. DSISR: 00800000. IAR : 0d39299c. SP : 36dda7e0. LR : 0d391810. CR : 24004442. CTR : 0cdb1d60. XER : 00000000.Traceback:. 0d39299c. 0d3e1a80. 0d407f64. 0 f79ef74. 0d47c590. 0d47d00c. 0f822178. 0fd22ccc. 30028d8c. 0ff25a90. 00000000. 00000000. 00000000. 00000000. 00000000 . 00000000. 00000000. 00000000. 00000000. 00000000.HwRel:CA01 - PEC:3JR20073BC - SN:YP14160B64C - MOD:MOD:eCCM-U_GE - SWver :UNB0814A110 } ;BTS_0002_00001;";

echo 'PEC'.between('PEC','-',$sLineSecond);
Genre ça ?
Désolé du retard de ma réaction, j'avais mis mon projet en stand-by. Merci beaucoup Nestecha. Merci vraiment.

Re: traitement de chaines de caractères

par Nestecha » 08 nov. 2014, 04:09

<?php

function after ($this, $inthat)
{
    if (!is_bool(strpos($inthat, $this)))
        return substr($inthat, strpos($inthat,$this)+strlen($this));
};

function before ($this, $inthat)
{
    return substr($inthat, 0, strpos($inthat, $this));
};


function between ($this, $that, $inthat)
{
    return before ($that, after($this, $inthat));
};

$sLine = "GRE_JEAN_JAURES;NW/UTRAN BTSEquipment/GRE_JEAN_JAURES Board/723467;10-04-2014 11:14:28;null;processing error;warning;active;softwareProgramError;TRDU/11 SOFTWARE DUMP;TRDU/11 SOFTWARE DUMP Specific Problem:TRDU/11 SOFTWARE DUMP, Cabinet:11, Shelf:10, Slot-position:11, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = GP_TRDU Pmdz :The system was power-cycled. - Cause:1 - RRH F/W:_BI_RE_TE_TR_BAND01_FV_1.2.18 - HwRel:AB04 - PEC:3JR21012AB - SN: GPCSTW1000501913 - MOD:TRDUBAND014C60W - SWver:UNB0814A110 } ;BTS_0002_00064;";

echo 'PEC'.between('PEC','-',$sLine);

$sLineSecond = "CINQ_AVENUES;NW/UTRAN BTSEquipment/CINQ_AVENUES Board/81;10-04-2014 15:47:45;null;processing error;warning;active;softwareProgramError;CCM/81 SOFTWARE DUMP;CCM/81 SOFTWARE DUMP Specific Problem:CCM/81 SOFTWARE DUMP, Cabinet:0, Shelf:0, Slot-position:81, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = Uptime : 52 days 04:05:43.Sequence num: 32.Thread name : tCpManager.Thread ID : 0x36ddb4b0.Error number: 0.Signal : 11.State and Misc Registers:. TRAP : 00000300. MSR : 0202d200. DAR : 00000096. DSISR: 00800000. IAR : 0d39299c. SP : 36dda7e0. LR : 0d391810. CR : 24004442. CTR : 0cdb1d60. XER : 00000000.Traceback:. 0d39299c. 0d3e1a80. 0d407f64. 0 f79ef74. 0d47c590. 0d47d00c. 0f822178. 0fd22ccc. 30028d8c. 0ff25a90. 00000000. 00000000. 00000000. 00000000. 00000000 . 00000000. 00000000. 00000000. 00000000. 00000000.HwRel:CA01 - PEC:3JR20073BC - SN:YP14160B64C - MOD:MOD:eCCM-U_GE - SWver :UNB0814A110 } ;BTS_0002_00001;";

echo 'PEC'.between('PEC','-',$sLineSecond);
Genre ça ?

traitement de chaines de caractères

par aly91 » 07 nov. 2014, 18:03

Bonjour,
Je viens demander de l'aide. J'ai un fichier texte. Après des explodes,je recupére des lignes que j'affiche ci dessous. En exemple :
Ceci forme une ligne ===>GRE_JEAN_JAURES;NW/UTRAN BTSEquipment/GRE_JEAN_JAURES Board/723467;10-04-2014 11:14:28;null;processing error;warning;active;softwareProgramError;TRDU/11 SOFTWARE DUMP;TRDU/11 SOFTWARE DUMP Specific Problem:TRDU/11 SOFTWARE DUMP, Cabinet:11, Shelf:10, Slot-position:11, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = GP_TRDU Pmdz :The system was power-cycled. - Cause:1 - RRH F/W:_BI_RE_TE_TR_BAND01_FV_1.2.18 - HwRel:AB04 - PEC:3JR21012AB - SN: GPCSTW1000501913 - MOD:TRDUBAND014C60W - SWver:UNB0814A110 } ;BTS_0002_00064;

Celle ci une autre ====>CINQ_AVENUES;NW/UTRAN BTSEquipment/CINQ_AVENUES Board/81;10-04-2014 15:47:45;null;processing error;warning;active;softwareProgramError;CCM/81 SOFTWARE DUMP;CCM/81 SOFTWARE DUMP Specific Problem:CCM/81 SOFTWARE DUMP, Cabinet:0, Shelf:0, Slot-position:81, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = Uptime : 52 days 04:05:43.Sequence num: 32.Thread name : tCpManager.Thread ID : 0x36ddb4b0.Error number: 0.Signal : 11.State and Misc Registers:. TRAP : 00000300. MSR : 0202d200. DAR : 00000096. DSISR: 00800000. IAR : 0d39299c. SP : 36dda7e0. LR : 0d391810. CR : 24004442. CTR : 0cdb1d60. XER : 00000000.Traceback:. 0d39299c. 0d3e1a80. 0d407f64. 0 f79ef74. 0d47c590. 0d47d00c. 0f822178. 0fd22ccc. 30028d8c. 0ff25a90. 00000000. 00000000. 00000000. 00000000. 00000000 . 00000000. 00000000. 00000000. 00000000. 00000000.HwRel:CA01 - PEC:3JR20073BC - SN:YP14160B64C - MOD:MOD:eCCM-U_GE - SWver :UNB0814A110 } ;BTS_0002_00001;

Ce que je voudrais c'est prendre PEC et la valeur qui suit exemple pour la ligne une PEC:3JR21012AB et pour la ligne deux PEC:3JR20073BC. J'y arive avec des explodes mais vu que les deux phrases n'ont pas la même taille, j'arrive à le récupérer sur la première et non sur la deuxième. Si possible avait vous une solution qui permettrait de le prendre dans toutes mes lignes et quelque soit sa taille.
Bien cordialement.