use ^ and $ to match the start and end of your string

^[0-9]{6}$
^[0-9]{6}\.[0-9]{3}$

Reference: http://www.regular-expressions.info/anchors.html

Also, as noted by Mikael Svenson, you can use the word boundary \b if you are searching for this pattern in a larger chunk of text.

Reference: http://www.regular-expressions.info/wordboundaries.html

You could also write both those regexes in one shot

^\d{6}(\.\d{3})?$
Answer from CaffGeek on Stack Overflow
Discussions

RegEx that does NOT match desired pattern
Hi all, I was looking into using the RegEx Actions to match multiple times - and that lead me to Peter's post: So I did what Peter suggested. That is working fine. But my search also lead me to this post by @JMichaelTX It seems like this would be more efficient or possible slightly quicker. More on forum.keyboardmaestro.com
🌐 forum.keyboardmaestro.com
1
0
June 19, 2020
Regex to test if strings exist in a string to match
For example my keyword string is Address Number Description and I have a string to match which is Address22 Number232 Description232 or Address’ss Numbers Descriptions or other combination. Since Address Number Description is present the the ff.examples which is Address22 Number232 Description232 ... More on forum.uipath.com
🌐 forum.uipath.com
1
0
October 9, 2020
Match multiple strings
I find peace in long walks. More on reddit.com
🌐 r/regex
5
2
August 21, 2022
Regex match anything but
The trick is to do the negative assertion at every point in the expression, and you need to anchor both the start and the end, something like /^(?:(?!red|green|blue).)*$/ should do the trick as shown here: https://regex101.com/r/lfeLIi/1 More on reddit.com
🌐 r/regex
7
4
June 30, 2022
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Regular_expressions
Regular expressions - JavaScript | MDN
For instance, to match the string "C:\" where "C" can be any letter, you'd use /[A-Z]:\\/ — the first backslash escapes the one after it, so the expression searches for a single literal backslash. If using the RegExp constructor with a string literal, remember that the backslash is an escape ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.text.regularexpressions.regex.match
Regex.Match Method (System.Text.RegularExpressions) | Microsoft Learn
Searches an input string for a substring that matches a regular expression pattern and returns the first occurrence as a single Match object. ... Searches the specified input string for the first occurrence of the regular expression specified ...
Find elsewhere
🌐
Medium
medium.com › @qdangdo › regex-a-way-to-match-any-pattern-of-string-1dd327130fc6
Regex: A Way to Match Any Pattern of String | by Quang Do | Medium
October 5, 2021 - The best way to learn is through practice so go to https://regex101.com/ and follow along. Let’s say I have a test string of “abcdefg” and “ABCDEFG”. Type in only a period in the regular expression box and you will see your words light up. It matches!
🌐
Splunk Community
community.splunk.com › t5 › Splunk-Search › Regular-expressions-to-match-a-specific-string-for-field › m-p › 454743
Regular expressions to match a specific string for... - Splunk Community
December 13, 2019 - If you have other OS types and different event formats, please share more samples so that the regex can be adjusted to your needs. --- What goes around comes around. If it helps, hit it with Karma ... If you want to pull more out of the user agent you could also use something like: \s\((?P<platorm>\w+)\;\s(?P<arch>\w+)\s(?P<os>[^\)]+)\) ... If you want to make it shorter you could also use (?i) (where i means: insensitive. Case insensitive match (ignores case of [a-zA-Z])
🌐
DEV Community
dev.to › xowap › the-string-matching-regex-explained-step-by-step-4lkp
The string-matching regex explained step by step - DEV Community
May 11, 2019 - The regex to match them is /\\(["\\\/bnrt])/ which allows you to see which character was caught in group 1. As you might know, the JavaScript String.replace() function allows to take a function as replacement.
🌐
W3Schools
w3schools.com › python › python_regex.asp
Python RegEx
If no matches are found, an empty list is returned: ... The search() function searches the string for a match, and returns a Match object if there is a match.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › match
String.prototype.match() - JavaScript | MDN
The match() method of String values retrieves the result of matching this string against a regular expression. const paragraph = "The quick brown fox jumps over the lazy dog. It barked."; const regex = /[A-Z]/g; const found = paragraph.match(regex); console.log(found); // Expected output: Array ...
🌐
Laserfiche Answers
answers.laserfiche.com › questions › 202200 › Regex--How-to-Pattern-Matching-starting-from-the-end-of-the-string-in-stead-of-the-front
Regex - How to Pattern Matching starting from the end of the string in stead of the front? - Laserfiche Answers
September 13, 2022 - 4) One option is to enhance your regex to account for, and ignore, the apartment information. 5) Parsing addresses is really hard because there's a lot of variability in them. If you can narrow the scope, that helps a lot (e.g., by using a Zone OCR in Quick Fields). Here's the regular expression I came up with, though I'll warn you that it is not robust: ... What it's doing: Match ADDRESS plus some other stuff (you probably don't need to be so exacting as in your post) until you reach a new line.
🌐
Reddit
reddit.com › r/regex › regex match anything but
r/regex on Reddit: Regex match anything but
June 30, 2022 -

Hello all.

Can anyone help me with the below request?

I need a regex condition that matches anything EXCEPT the specified strings. I have tried the following regex, but unfortunately it does not match if I have a string that contains one of the values listed below, e.g. "blue dragon" does not match because it contains "blue". I need it to match if it isn't exactly the values I have in the regex, so if I have "blue dragon" it matches still, although I have "blue" in the regex.

Thanks in advance!

^(?!.*(red|green|blue))
🌐
W3Schools
w3schools.com › jsref › jsref_match.asp
W3Schools.com
The match() method returns null if no match is found. ** If the search value is a string, it is converted to a regular expression.
🌐
LeetCode
leetcode.com › problems › regular-expression-matching
Regular Expression Matching - LeetCode
Regular Expression Matching - Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: * '.' Matches any single character.
🌐
RegexOne
regexone.com
RegexOne - Learn Regular Expressions - Lesson 1: An Introduction, and the ABCs
The first thing to recognize when using regular expressions is that everything is essentially a character, and we are writing patterns to match a specific sequence of characters (also known as a string).
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.text.regularexpressions.regex.matches
Regex.Matches Method (System.Text.RegularExpressions) | Microsoft Learn
The Matches(String, String, RegexOptions, TimeSpan) method is similar to the Match(String, String, RegexOptions, TimeSpan) method, except that it returns information about all the matches found in the input string, instead of a single match.