Search code examples
regexnotepad++

Finding words with dash/hyphen and without in same regex?


Have the following examples:

Find: \(([A-Z][A-Za-z-\s])\) -- (Ki-Woo)
Find: \(([A-Z][A-Za-z\s]
)\) -- (Drunk)

How do I find both (Ki-Woo) and (Drunk) with same regex ?

Also, how do I find instances where there should be a SPACE's?

<b>MR.SMITH ------> <b> MR. SMITH

Should be a space between <b> and MR. and SMITH

Thanks in advance !

EDIT:

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

Still not sure how to pass result to Replace: field in NP++ ? ?

The ($1) worked on a similar Find: below for MR. SMITH: but not on the one above with (Ki-Woo);(Drunk);(Woman 1)

Find: ([A-Z][A-Z\.\s]*\:+)
Replace: \<font color\=\"\#FFA500\"\>\<b\>($1)\<\/b\>\<\/font\>

Not sure how the ($1) .... Watching more UTube


Solution

  • For the first question, use: \([A-Z)[a-z]*(?:-[A-Z][a-z]*)*\)

    Demo & explanation

    For the second:

    \h*MR\.\h*[A-Z]+

    Demo & explanation