regexnotepad++icd

Find (ICD9 code) and replace parentheses with |


I'm using Notepad++ v6.9.2. I need to find ICD9 Codes which will take the following forms:

and

replace the first ( with | and the ) and single space behind second with |.

EXAMPLE

(305.11) TOBACCO ABUSE-CONTINUOUS

Becomes:

|305.11|TOBACCO ABUSE-CONTINUOUS

OTHER CONSIDERATIONS:

There are other places with parentheses but will only contain letters. Those do not need to be changed. Some examples:

UE (Major) Amputation
(282.45) THALASSEMIA (ALPHA)
(284.87) RED CELL APLASIA (W/THYMOMA)
Pain (non-headache) (338.3) Neoplasm related pain (acute) (chronic)

Becomes

UE (Major) Amputation
|282.45|THALASSEMIA (ALPHA)
|284.87|RED CELL APLASIA (W/THYMOMA)
Pain (non-headache) |338.3|Neoplasm related pain (acute) (chronic)

Solution

  • You can use a regex like this to match ICD9 codes:

    [EV]\d+\.?\d*
    

    This covers both E and V codes and cases where the . is omitted (in my experience this is not uncommon). Use this regex to match the portions of text you need:

    \(([EV]?\d+\.?\d*)\)\s?
    

    The outer parentheses are escaped to match literal ( and ) characters, and the inner parentheses create a group for replacement (\1). The \s? at end will capture an optional space after the parentheses.

    So your Notepad++ replace window should look like this:

    Notepad++ replace