I want to find strings that DO NOT match a specific character sequence. For instance:
sort of
REGEX = r'[^XY]*'
I would like to look for strings that have any number of characters except X and Y next to each other ... REGEX above does not work as it blocks X and Y separately.
What about:
if "XY" not in s: print "matched" else print "not matched"
Or is it for inclusion in some longer regular expression? Then maybe you want to get a negative expression:
REGEXP="...(?!XY)..."
EDIT: fixed typo
There are several ways to do this.
^(?!.*XY).*$
lookahead XY . , , , . .* .
XY
.*
^(?:(?!XY).)*$
(.), , lookahead , XY.
.
^(?:[^X]+|X(?!Y))*$
, X X, Y.
X
Y
DOT_ALL, . , - [^X] - .
[^X]
Source: https://habr.com/ru/post/1788057/More articles:SHA1 с BASE64 в классе java util не генерирует правильный пароль - javaAndroid: java.lang.NullPointerException в android.graphics.Canvas.drawLine(Canvas.java:809) (возможно, связано с моим ресурсом, пригодным для рисования) - androidFormatting Objective-C for blogging - blogsExclude tag from regex not remove from text? - regexMap a secondary domain to a subdirectory using mod_rewrite - dnsSystem.Linq.Dynamic not working for Entity Framework - dynamicView Tomcat context startup exceptions in IDEA - intellij-ideaCut part of url using jquery - jqueryIntelliJ IDEA Scala plugin problem - scalaC # HttpListener Cookies expiring after a session, even if the expiration time is set - c #All Articles