stripping texts ".24 to the next line break"

Welcome Forums General PowerShell Q&A stripping texts ".24 to the next line break"

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
2 months, 3 weeks ago.

  • Author
    Posts
  • #129579

    Participant
    Topics: 2
    Replies: 2
    Points: 18
    Rank: Member

    code$Location = "C:\weather\weatherdec.txt"
    code$Location1 = "C:\weather\weatherdec1.txt"
    code$Change = Get-Content $Location

    code$Change | Select-Object -Skip 17 | ForEach-Object {$_ -replace ".24" , ""} |Set-Content $Location1

    FZPN40 PHFO 112212
    HSFNP 
    
    HIGH SEAS FORECAST
    NATIONAL WEATHER SERVICE HONOLULU HI
    2300 UTC TUE DEC 11 2018
    
    SUPERSEDED BY NEXT ISSUANCE IN 6 HOURS
    
    SEAS GIVEN AS SIGNIFICANT WAVE HEIGHT...WHICH IS THE AVERAGE HEIGHT
    OF THE HIGHEST 1/3 OF THE WAVES. INDIVIDUAL WAVES MAY BE MORE THAN
    TWICE THE SIGNIFICANT WAVE HEIGHT.
    
    THIS HIGH SEAS FORECAST USES 1-MINUTE AVERAGE WINDS WHICH MAY BE
    HIGHER THAN 10-MINUTE AVERAGE WINDS.
    
    SECURITE
    
    NORTH PACIFIC EQUATOR TO 30N BETWEEN 140W AND 160E
    
    SYNOPSIS VALID 1800 UTC DEC 11 2018.
    24 HOUR FORECAST VALID 1800 UTC DEC 12 2018.
    48 HOUR FORECAST VALID 1800 UTC DEC 13 2018.
    
    .WARNINGS.
    
    ...GALE WARNING...
    .NE TO E WINDS 25 TO 35 KT AROUND THE MAIN HAWAIIAN ISLANDS. FOR 
    DETAILS SEE THE LATEST COASTAL WATERS FORECAST ISSUED BY NWS 
    HONOLULU UNDER WMO HEADER FZHW40 PHFO AND AWIPS HEADER CWFHFO. 
    .24 HOUR FORECAST WINDS DIMINISHED BELOW 35 KT AROUND THE MAIN 
    HAWAIIAN ISLANDS.
    
    .SYNOPSIS AND FORECAST.
    
    .LOW 04N171E 1006 MB MOVING NW 10 KT. TROUGH FROM 12N174E TO LOW 
    TO 03N167E TO 02N160E NEARLY STATIONARY. SCATTERED MODERATE TO 
    STRONG TSTMS WITHIN 360 NM OF A LINE FROM 14N179E TO 08N175E TO
    00N172E. 
    .24 HOUR FORECAST LOW DISSIPATED. TROUGH FROM 12N1771 TO 09N168E 
    TO 03N165E. 
    .48 HOUR FORECAST TROUGH MOVED W OF AREA. 
    
    .FRONT FROM 30N174E TO 25N160E MOVING E 20 KT N OF 29N AND NEARLY
    STATIONARY ELSEWHERE. 
    .24 HOUR FORECAST FRONT FROM 30N168W TO 29N177W TO 30N175E.
    .48 HOUR FORECAST FRONT DISSIPATED. 
    
    .NE TO E WINDS 20 TO 30 KT ENTIRE AREA FROM 05N TO 22N...AND
    FROM 22N TO 27N E OF 156W.
    .24 HOUR FORECAST NE TO E WINDS 20 TO 30 KT FROM 05N TO 26N 
    W OF 167W...FROM 05N TO 22N BETWEEN 167W AND 150W...AND FROM 10N 
    TO 23N E OF 150W. 
    .48 HOUR FORECAST NE TO E WINDS 20 TO 30 KT IN AREA BOUNDED BY A 
    LINE FROM 25N160W TO 16N148W TO 07N150W TO 06N164W TO 06N176E TO 
    13N160E TO 20N160E TO 21N175E TO 26N174W TO 25N160W. 
    
    .48 HOUR FORECAST NEW COLD FRONT THROUGH 30N160E. 
    
    .RIDGE FROM 30N169W TO 28N172E MOVING E 15 KT...AND GRADUALLY 
    ERODING FROM THE W. 
    
    .SEAS 12 TO 14 FT FROM 06N TO 20N BETWEEN 147W AND 167E. ELSEWHERE 
    SEAS 8 TO 12 FT ENTIRE AREA...EXCEPT SEAS 8 FT OR LESS S OF A LINE 
    FROM 10N160E TO 00N174E.
    .24 HOUR FORECAST SEAS 12 TO 14 FT FROM 05N TO 22N W OF 154W. 
    ELSEWHERE SEAS 8 TO 12 FT ENTIRE AREA...EXCEPT SEAS 8 FT OR LESS 
    S OF A LINE FROM 08N160E TO 00N177E...AND S OF A LINE FROM 08N140W 
    TO 00N160W. 
    .48 HOUR FORECAST SEAS 12 T0 15 FT FROM 05N TO 18N BETWEEN 154W AND 
    172E...AND FROM 10N TO 18N W OF 172E. ELSEWHERE SEAS 8 TO 12 FT 
    ENTIRE AREA...EXCEPT SEAS 8 FT OR LESS S OF A LINE FROM 08N160E TO 
    00N175E...AND S OF A LINE FROM 08N140W TO 00N150W. 
    
    .REMAINDER OF AREA WINDS 20 KT OR LESS. SEAS 8 FT OR LESS.
    
    .ITCZ FROM 08N140W TO 06N155W TO 04N170W. SCATTERED MODERATE TSTMS
    FROM 04N TO 08N BETWEEN 153W AND 159W. ISOLATED MODERATE TSTMS
    FROM 03N TO 07N BETWEEN 162W AND 171W. 
    
    $$
    
    .FORECASTER BIRCHARD. HONOLULU HI.
    
    

    My question, If you go to the text above you will see ".24" throughout the text. I want to strip from the ".24 to the next linebreak" without having to type out word for word or use "........." btw I'm using powershell

  • #129590

    Participant
    Topics: 0
    Replies: 38
    Points: 197
    Helping Hand
    Rank: Participant

    This should do it:

    $Change | Select-Object -Skip 17 | ForEach-Object { $_ -replace '\.24.*','' } | Set-Content $Location1

    A note: $Change contains no line breaks. Get-Content has removed them and returned an array of lines. Set-Content puts them back.

  • #137561

    Participant
    Topics: 2
    Replies: 2
    Points: 18
    Rank: Member

    Phansen I made a mistake can you do it for a paragraph break?

You must be logged in to reply to this topic.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort