Question Rechercher plusieurs pattern sur une seule ligne

Plus d'informations
il y a 4 ans 5 mois #29333 par Toper
Bonjour@ tous,
je cherche le moyen de trouver dans un fichier plusieurs pattern contenues sur une seule ligne.
Ex: une ligne comme celle-ci:
[code:1]CPEO|C|04131007059220183995|PREP|171019113859|AFFR||BGJ-62|5246508|1710191250|17
10191300||000000000|000000000|000000002|000000000|000000001|[/code:1]
J'aimerai ne chercher la ou les lignes qui ne contiennent QUE '04131007059220183995' ET '171019113859' ET '1710191250' par exemple.
Est-ce un select-string + -pattern ou un gc + where-object ?
Merci :)

Powershell: la vie est belle :)

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 5 mois #29337 par Hicham Madini
Salut gregmurf, slt le Forum,

essaie comme ca:

[code:1]$testfile = \"C:\temp\test.txt\"
(Get-Content $testfile) -match '04131007059220183995.*171019113859.*1710191250'[/code:1]

Bonne journée

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 5 mois #29338 par Toper
Bonjour,
merci de té réponse.
Non ça ne fonctionne pas. Il me ramène l'entièreté du fichier.
Et si je rajoute du texte sur d'autres lignes, il me les ramène aussi...

Powershell: la vie est belle :)

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 5 mois #29339 par Hicham Madini
t'as un fichier exemple??

essaie avec mon fichier test, ca doit fonctionner!!

La pièce jointe test-9c8cfe0347589ee516459f0efa8d664a.txt est absente ou indisponible

<br><br>Message édité par: hichammadd, à: 24/10/19 08:07

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 5 mois #29340 par Toper
J'ai testé comme ceci:
Contenu du fichier.txt:
[code:1]EOP|2406|U|04577030019860913776|CLI|PRO|N|O|EXP|||N|N|03001986||2410190851||2410190852|1||2410190851|||1||04577||||AFFR|||SB|DIR||OPT|||1|||||||
LOP|2404|U|04577030019860913776|0001|O|STOC|03001986||2410190851|0001||1611545780|PIECE|PAPIER PROTECT|||||||||||||||||||||101.47||000000001||15.00|0.00|86.25|86.25
DOP|2400|U|04577030019860913776|BL VALORISE|-|N
FOP|2400|U|04577030019860913776[/code:1]

Script PSH:
[code:1]$testfile = \&quot;c:\fichier.txt\&quot;
(Get-Content $testfile) -match 'EOP|2406|U|04577030019860913776|CLI|PRO|N|O|EXP|||N|N|03001986|.*AFFR'[/code:1]

Résultat:
[code:1]PS C:\Windows\system32&gt; $testfile = \&quot;c:\fichier.txt\&quot;
(Get-Content $testfile) -match 'EOP|2406|U|04577030019860913776|CLI|PRO|N|O|EXP|||N|N|03001986|.*AFFR'
EOP|2406|U|04577030019860913776|CLI|PRO|N|O|EXP|||N|N|03001986||2410190851||2410190852|1||2410190851|||1||04577||||AFFR|||SB|DIR||OPT|||1|||||||
LOP|2404|U|04577030019860913776|0001|O|STOC|03001986||2410190851|0001||1611545780|PIECE|PAPIER PROTECT|||||||||||||||||||||101.47||000000001||15.00|0.00|86.25|86.25
DOP|2400|U|04577030019860913776|BL VALORISE|-|N
FOP|2400|U|04577030019860913776[/code:1]

Powershell: la vie est belle :)

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 5 mois #29342 par Hicham Madini
[code:1]$testfile = \&quot;c:\fichier.txt\&quot;
(Get-Content $testfile) -match 'EOP`|2406`|U`|04577030019860913776`|CLI`|PRO`|N`|O`|EXP`|`|`|N`|N`|03001986`|.*AFFR'[/code:1]<br><br>Message édité par: hichammadd, à: 24/10/19 09:06

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.077 secondes
Propulsé par Kunena