Page 1 of 1
RegEx to look for word
Posted: Tue May 22, 2012 3:56 pm
by hoachen
I am trying to have a regular expression to find and delete those I don't need it. For example.
Summary of this topic.
Capacity: 2090
IP address: 90:400:00
Subnet mask: 255.0.555
Status: Good
ID: 1233
I only want to the whole line for capacity, IP address and I don't need the rest. But, after the colon it might be few spaces or a tab before the any number or text.
After the regex, the result should display:
Capacity: 2090
IP address: 90:400:00
ID: 1234
Status: Good
Is anyone think this is possible to accomplish?
Thanks for reading this post.
Posted: Tue May 22, 2012 8:36 pm
by MudGuard
it is not clear what you really want.
You write that you only want to keep lines containing capacity and ip address.
But in the result you want to hav, there are ID and status lines as well (in changed order, and with increased ID value).
If you only want to keep lines with capacity and ip:
clear all bookmarks
find capacity, mark all
find ip address, mark all
invert all bookmarks
delete bookmarked lines.
Posted: Tue May 22, 2012 8:44 pm
by hoachen
I need the entire line.
Capacity: 2090
IP address: 90:400:00
ID: 1234
Status: Good
Posted: Tue May 22, 2012 8:54 pm
by MudGuard
WHICH ENTIRE LINE?
You show four lines and tell us you need _THE_ whole line ...
You are confusing. You originally show a six-line text sample, tell us you need only the two lines containing ip and capacity, but the wanted result shows four lines (with changed order and changed content). And then you tell us you need only one line, but that line completely, and again show four lines as wanted result.
Sorry, I can't think of any way to produce a single line result containing four lines, two of which you told us you don't need ...
Posted: Tue May 22, 2012 9:24 pm
by hoachen
I might left out other two items on the description part, but not confuse as you thought.
Never mind. I figure it out.
Thanks!
Posted: Thu Jun 14, 2012 8:36 am
by bloodbaz
I suggest you try MudGuard's bookmark approach.
You can adapt his approach to choose whichever lines you want to keep or remove. The approach by definition works on whole lines as you were asking for.