Attempt to match a word if it is not contained in asterisks. Here is what I have:
(?<!\*)\b(word)\b(?!\*)
The problem is that it will not match *word or word* , since I want it to match every permutation, except for *word* .
*word
word*
*word*
Try this solution, it should match any word, not just "word":
(?<!\*)\b\w+\b|\b\w+\b(?!\*)
The key point here is the search for two situations in which an asterisk may appear, that is, at the beginning of OR at the end of a word.
Then you need alternation.
(?<!\*)\bword\b|\bword\b(?!\*)
See at Regexr .
Your problem is that the whole regex does not work as soon as one statement is true. My way to resolve * on the one hand, but it fails when * is on both sides.
*
Some divertissement:(?(?<=\*)word(?!\*)|word(?=\*))
(?(?<=\*)word(?!\*)|word(?=\*))
Explanation:
(? # if (?<=\*) # there is * before word(?!\*) # then match word not followed by * | # else word(?=\*) # match word followed by * ) # end if
Demo version
Source: https://habr.com/ru/post/1486773/More articles:Notepad ++ or netbeans plugin for marking text in html - htmlHow to vectorize the sum of point products between a normal and a set of points - vectorizationOverwritten methods do not contain self? - pythonBOOST_STATIC_ASSERT_MSG - no error message - c ++Fan Speed ββ(CPU) - c #Script and command line access function - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1486775/static-access-to-entity-manager-in-spring-and-unusual-architecture&usg=ALkJrhjKxSfEB7LxW0BDKH14ZQzFxzRurwhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1486776/oracle-sql-view-multiple-rows-to-one-with-help-of-foreign-key&usg=ALkJrhiTny9qCjOLDpzCwWRhQ3JI0AeGaACreating a hyperlink using apache poi - javalist values ββin a dropdown using ViewData and th viewcode to list it? - c #All Articles