\W
is the opposite of \w
and \D
is the opposite of \d
.
It’s just like \S
is the opposite of \s
.
\W
and \D
respectively will match what \w
and \d
respectively don’t match.
You can have a look at this site for some more explanation.
\w
typically matches [A-Za-z0-9_]
(ignoring the foreign characters)
\W
thus matches [^A-Za-z0-9_]
And since
\d
typically matches [0-9]
(ignoring the foreign digits)
\D
thus matches [^0-9]
Related Contents:
- Check if a string matches a regex in Bash script
- How to use ‘-prune’ option of ‘find’ in sh?
- How to match a pattern given in a variable in awk?
- Sed to extract text between two strings
- Recursively change file extensions in Bash
- How do I extract a string using a regex in a shell script?
- How to do a non-greedy match in grep?
- Using regular expressions to parse HTML: why not?
- Why is this regex allowing a caret?
- RegEx: Grabbing values between quotation marks
- RegEx for matching UK Postcodes
- Getting parts of a URL (Regex)
- Regex (grep) for multi-line search needed [duplicate]
- Bash Regular Expression — Can’t seem to match any of \s \S \d \D \w \W etc
- How to get domain name from URL
- Is there something like a counter variable in regular expression replace?
- Regular Expressions and negating a whole character group [duplicate]
- Regex Last occurrence?
- What is a regular expression for a MAC Address?
- RegExp exclusion, looking for a word not followed by another
- Regular expression to match characters at beginning of line only
- Using regexes, how to efficiently match strings between double quotes with embedded double quotes?
- Jmeter extracting fields/parsing JSON response
- Using sed to delete all lines between two matching patterns
- HTML5 Form Input Pattern Currency Format
- What do comma separated numbers in curly braces at the end of a regex mean?
- Find the location of a character in string
- Regex: Remove lines containing “help”, etc
- Regular Expression Lookbehind doesn’t work with quantifiers (‘+’ or ‘*’)
- Zero-Length regexes and infinite matches?
- Regular expression search replace in Sublime Text 2
- Regex to match month name followed by year
- Use a function in Powershell replace
- regex to match a single character that is anything but a space
- Regex to get the words after matching string [duplicate]
- How .* (dot star) works? [closed]
- Regex for alphanumeric, but at least one letter
- What is the Regular Expression For “Not Whitespace and Not a hyphen”
- Regular Expression only match if String ends with target
- Random Text generator based on regex [duplicate]
- Why are there so many different regular expression dialects?
- Short example of regular expression converted to a state machine?
- Can I use Perl regular expressions to match balanced text?
- Regex for PascalCased words (aka camelCased with leading uppercase letter)
- Email validation using regular expression in JSF 2 / PrimeFaces
- RegEx to match comma separated numbers with optional decimal part
- Remove duplicates from text file based on second text file
- Bash – Regex for HTML contents
- Using sed and grep/egrep to search and replace
- Regular expression to find two strings anywhere in input