This StackOverflow answer shows how to generate mathematiclly proven regular expression to match a line that doesn't contain a word.
If you want to do the same, you need to run vcsn locally since vcsn sandbox doesn't work anymore.
- Start vcsn using Docker
docker run --rm -p 8888:8888 lrde/vcsn
- Open http://localhost:8888
- Create new notebook
- Insert new cell
- Add this code to the cell
import vcsn
# your string
input = 'nomatch'
# use proper charset
c = vcsn.context('lal_char(a-z), b')
e = c.expression('(%s){c}' % input)
a = e.automaton()
print(
'^(' +
str(
a.expression()
).replace('+','|') # + is usually denoted |
.replace('\e','') # \e denotes the empty word
.replace('[^]','.') # [^] is usually written .
+ ')$'
)
- Run notebook
- Simplify generated regex: http://ivanzuzak.info/noam/webapps/regex_simplifier/