I am trying to use a Regular Expression in the Find and Replace feature within Google Colab, located in the left side tool bar, but it does not seem to recognize it. Is there a specific Regular expression that Google Colaboratory uses?
I'm trying to find фll occurrences of xtst
excluding occurrences xtst_
, xtst2_
.
Expression I've tried:
xtst(?!\_+|\d+)
(xtst(?!\_+|\d+))
(xtst)(?!\_+|\d+)
r"(xtst(?!\_+|\d+))"
This string works, but is incorrect as it's looking for all occurrences of x
,t
,s
,t
everywhere.
[xtst](?!\_+|\d+)
Test string:
xtr, xtst, ytr, ytst =
Result of working RE for the string above would be:
xtst
The 1st RE is working fine at regex101.com as well as the 2nd, and 3rd RE.
You should not escape the underscore _
, it is a word character, and escaping word characters is not always allowed across regex libraries.
What you want to match is xtst
not followed with either a digit or underscore, so you can use
xtst(?!_|\d)
xtst(?![\d_])
xtst(?![0-9_])