0

I must find the letter (diacritics/Accent Marks) î in the middle of the words, but not the letter î at the beginning or at the end of the words.

For example:

1.stăpînii

2.înstăpanit

3.coborî

4.înfornît

So the regex must find the letter î just from words like the first one: stăpînii.

The 2 and 3 word have the letter î at the beginnind or at the end. So those must be ignore from finding.

The 4 case is tricky. It starts with î and also has an î in the middle. So, only the second î must be find by regex.

FINAL: Regex must find the letter îfrom the first word stăpînii and also must find the second î from the last word înfornît

3 Answers 3

1

You want to work with lookahead and lookbehind here:

(?<=\w)î(?=\w)

Explanation:

(?<=\w)î(?=\w)  
(?<=  )         #positive lookbehind, "must be preceeding the match"
    \w     \w   #match any word character
       î        #character to match
        (?=  )  #positive lookahed, "must be following the match"

Example

2
  • Fixed, had the wrong regex flair selected Commented Mar 25, 2022 at 22:30
  • thanks , works ;)
    – Just Me
    Commented Mar 26, 2022 at 5:45
2

Much more efficient than lookaround, use non word-boundary, it reduces the step number by 2.

  • Ctrl+F
  • Find what: \Bî\B
  • CHECK Wrap around
  • CHECK Regular expression
  • Find All in Current Document

Explanation:

\B          # NON word-boundary, make sure we have a word character before
î           # letter î
\B          # NON word-boundary, make sure we have a word character after

Screenshot:

enter image description here

1
  • thanks, toto. I didn't know about this ;)
    – Just Me
    Commented Mar 27, 2022 at 11:08
1

For Notepad++, use (?<!\<)î(?!\>)

  • (?<!...) - negative lookbehind (i.e: preceeding text doesn't match)
    • \< - start of word boundary (regex extension)
  • (?!...) - negative lookahead (i.e: following text doesn't match)
    • \> - end of word boundary (regex extension)
1
  • thanks , works ;)
    – Just Me
    Commented Mar 26, 2022 at 5:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .