0

Based on previous help from here, I am using Negative Lookahead but it does not work in this instance. I need it not to capture "Váš" at the beginning of sentence. Could you please help me with https://regex101.com/r/Tv72vp/2?

The regex is

\b(?!(?:váš|Váš|náš|Náš)\b)\w*eš\b|íš\b|áš\b

The string I need to match is

Náš počítač je ideální společník na cesty.
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
  • 1
    So what are expected matches and why? Note there is no `Váš` at the sentence start. – Wiktor Stribiżew Feb 22 '23 at 21:15
  • You may want to use `\s` instead of the first `\b`. See https://stackoverflow.com/a/7606358/15032126 – Ignatius Reilly Feb 22 '23 at 21:25
  • Something like this `(?<=váš|Váš|náš|Náš\s)\w*(eš\b|íš\b|áš\b)` is _close_ to what you need, but the problem is that `\w` is just a short-hand for `[a-zA-Z0-9]` and does not include characters like `č`. – Ignatius Reilly Feb 22 '23 at 21:28
  • Does this answer your question? [What's a good regex to include accented characters in a simple way?](https://stackoverflow.com/questions/24676691/whats-a-good-regex-to-include-accented-characters-in-a-simple-way) – Ignatius Reilly Feb 22 '23 at 21:28
  • Sorry, I meant not to capture Náš at the beginning. I need it to capture all words ending -eš, -áš, -íš but not to capture words Váš, váš, Náš, náš (even at the beginning of sentence). \w worked well with accents so far. When I use only \w*(eš\b|íš\b|áš\b) and type e.g. šřeš it is captured. (?<=váš|Váš|náš|Náš\s)\w*(eš\b|íš\b|áš\b) does not work for me. When I delete náš|Náš from it, it does not capture anything. – stacker Feb 23 '23 at 23:03

1 Answers1

-1

I think you can do it without Negative Lookahead, if I understand the question corretly like this:

https://regex101.com/r/0ZXSFs/1

Telexx
  • 420
  • 2
  • 11