Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a regex 1

Status
Not open for further replies.

w5000

Technical User
Nov 24, 2010
223
PL
Hello,
I want a regex (with OR as below) also matching "md" lines in which 3rd column is not a string "active". Is it possible?

Qy2Cmu.jpg
 
Hi

Sadly you can not say "not the string" like that. For negation the best option is negative look-ahead assertion : [tt](?!active)[/tt]. But that being a zero-width assertion, you will still need to match whatever is there with something generic, like [tt].+[/tt] or [tt].+?[/tt]. So the 3[sup]rd[/sup] part of you expression would look like something this :
Code:
md[[:digit:]]+[[:space:]]+:[[:space:]]+(?!active).+?[[:space:]]+raid[[:digit:]]+

But in practice I would probably use something different.

Feherke.
feherke.ga
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top