regex


How do I capture words that are different from specific word using RegEx?


I wanted to know, how do I capture any word which is not exactly "yellow". e.g.: "red".
I have tried the following regex:
(?!(yellow))
Debuggex Demo
... but I have two problems:
It does not capture (creates a backreference) for matching expression (e.g.: "red")
"yellowwwwww" does not match my regex, even though it is different from "yellow".
Can you help me correcting my regex?
Thanks!
To capture any word which is NOT yellow you can use:
\b((?!\byellow\b)\w+)\b
Online Demo: https://www.debuggex.com/r/S-qTilRd3WJqUP6x
How about
(?!yellow$)
The inner parenthesis in your original regex are needed only if you want to capture the group
The $ ensures that only yellow will not match. If you want to use it inside a phrase use this instead
(?!yellow\b)

Related Links

How to chunk text “from the back” in perl.
Notepad++: regex as replace
Regex to replace stored procedure params with declarations
Regex Negation on part of word
capturing inner matches #2 and #4 and replace them
Parsing .torrent-file using ANTLR
“sed” command to remove a line that match an exact string on first word [duplicate]
R: Detecting emoticons using regex
Append Data to a specific line number using SED/AWK in Unix
Issues with regex for apache to exclude certain things
R - Manipulate string based on pattern
Remove the text outside the first brackets in R
Regular expression to extract strings after “/” in r [duplicate]
Remove spaces before file extension with regex
Invert match in regex
How do I validate an IPv6 address in bash?

Categories

HOME
mocking
dom
web-applications
runnable
tags
apache-pig
parse.com
azure-web-sites
prebuild
styling
wikipedia
api.ai
spi
c++14
google-analytics-api
python-xarray
autofac
librsvg
bluej
scope
scrollbar
postgresql-9.5
monaco-editor
stm32f4discovery
hp-alm
nintex-workflow
spark-graphx
ormlite-servicestack
semantics
microphone
hough-transform
liferay-aui
naturallyspeaking
smallbasic
simple-html-dom
flatbuffers
valueinjecter
android-imageview
whatsapi
vrtk
advanced-installer
deep-copy
nio
eve
consistency
automata-theory
linear
slt
gulp-babel
oracle-aq
pseudo-element
requirements-management
clientscript
asyncsocket
paypal-webhooks
zbar
gpt
zenity
kombu
configuration-profile
nsd
android-location
airplay
ospf
uikeyboard
phone-number
pyenchant
translate3d
alienvault
abort
windows-universal
emberfire
movie
generalization
vendor
mks
esx
symfony-2.5
concurrentdictionary
sirtrevor
magic-unipaas
disk-io
requiredfieldvalidator
junit-runner
transport-stream
mms-gateway
xcode4.2
sparc
shebang
cakephp-2.1
headless-browser
vim-fugitive
intel-8080
websolr
openid4java
openfeint
xoom
scramble
project-settings
sqlitemanager
code-statistics
stsadm

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App