0 votes

Trying to scan a file to flag the first word in all procedure steps which isn't in a case-sensitive upper-case list of words.

This is working pretty well for finding the first word in a sentence:

^\s*([a-zA-Z]+)

but if the step contains two or more sentences, it misses the start of the other sentences.

How to provide a list of words to exclude from the match is also killing me. Other requirements are that the exclusion should only be valid if the upper case word IS NOT in bold.

Example:
Example excluded word list

(CLOSE|OPEN|DISCONNECT|LOCK|PURGE|DRAIN|RECORD)

Show these lines:

 First **OPEN** valve 3.   (*OPEN* isn't the first word)
 RECORD the pressure.   (List word isn't bolded)
 **Close** bypass valve 4.  (**Close** isn't in all caps)
 **DISCONNECTthe** hose.  (No space between **DISCONNECT** and the, so not in the list)
 **DRAIN** the pump.  **PURGE** it with water.  (Second step is not at the first of a line)
 

Don't show these lines

**LOCK** out the pump.
**CLOSE** the discharge valve.
**PURGE** the tank. 

Thanks for any help...

asked by (50 points)
Your example shows the first line highlighting 'OPEN' why isn't 'First' highlighted?

1 Answer

0 votes

Not the complete solution but you need to use something along the lines of:

^(?!CLOSE|OPEN|DISCONNECT|LOCK|PURGE|DRAIN|RECORD).*$

answered by (1.4k points)
...