Delete all on line AFTER specified text is found

A place to try and solve your RegEx problems.
Post Reply
schnarkle
Posts: 9
Joined: Thu Aug 18, 2016 2:37 am

Delete all on line AFTER specified text is found

Post by schnarkle »

Hello,

I'd like to clean up a weather page on a daily basis to go from this:

Billings, MT;93;62;80;53;Not as warm;NNE;10;44%;20%;8
Birmingham, AL;80;70;81;69;Thunderstorms;SSW;6;81%;90%;4
Bismarck, ND;92;57;92;63;Mostly sunny;SE;12;46%;36%;8
Boise, ID;85;51;77;49;Mostly sunny, nice;N;8;36%;0%;8

to this

Billings, MT;93;62;80;53;
Birmingham, AL;80;70;81;69;
Bismarck, ND;92;57;92;63;
Boise, ID;85;51;77;49;

I can find using \;\d+\;\d+\;\d+\;\d+\;
but I can't delete to the end of the line.
I tried adding \r\n to the end of the above like this: \;\d+\;\d+\;\d+\;\d+\;\r\n

but that replace all my City information with the actual regex code.

Any ideas? I feel like i'm missing something very simple....

thanks!
schnarkle
Posts: 9
Joined: Thu Aug 18, 2016 2:37 am

Re: Delete all on line AFTER specified text is found

Post by schnarkle »

anyone? :)
User avatar
DigitalVolcano
Site Admin
Posts: 1717
Joined: Thu Jun 09, 2011 10:04 am

Re: Delete all on line AFTER specified text is found

Post by DigitalVolcano »

You are almost there - this should do it:
(be sure the options "Multi-line anchors" and "Dot Matches Newline" are turned OFF)
Regex:

Code: Select all

(\;\d+\;\d+\;\d+\;\d+\;).*
Replace:

Code: Select all

$1
Post Reply