Hank K
Hank K

Reputation: 151

Find contents of SQUARE brackets, excluding the brackets

Find the following that start with UPPERCASE letter:

[Ki-Woo]
[Roger]
[Woman 1]
[Dr. Freeman]
[Dr. West]
[Anne Marie O'Donnell]
[Anne-Marie O'Donnell]
[Gary Wells]
[Gary L. Wells]
[R. H. Brown]
[Roger H. Brown]
[J. Edgar Hover]

Exclude/ignore the ones starting with lowercase letter:

[young Ashley]
[reporter 1]
[woman 1]

Here's what I currently have which finds ALL of them:

Find: \[([A-Z]*(?:(?:.*|\h*)[A-Z0-9][a-z]*)*)\]

Replace: $1\:

EDIT: Demo:

Thank You in Advance, Hank

Upvotes: 1

Views: 124

Answers (1)

Matthias
Matthias

Reputation: 7521

I think this would already match your requirements:

\[([A-Z].*?)\]

The second expression that was asked for in the comment:

\[([a-z].*?)\]\h.*

Both in one expression (but with different capture groups...):

\[(?:([A-Z].*?)\]|([a-z].*?)\]\h.*)

Upvotes: 2

Related Questions