## I need to write a regex that recognize all numbers with coma separated or not, excluding 4 digits numbers

I want to capture all number with comma or not comma-separated excluding 4 digit numbers:

I want to match these numbers (in my case the number are separated by 3 digits always)

978,763,835,536,363 123 123,456 123456 7456 3400

excluding the years like

1200 till 2020

I have written this

regex_patterns = [ re.compile(r'[0-9]+,?[0-9]+,?[0-9]+,?[0-9]+') ]

it works good ,I do not how exclude years from these number...many thanks

Of course, I am working o the sentients, the number are inside the sentences not necessity at first fo the line like this

-Thus 60 is to 41 as 100,000 is to 65,656½, the appropriate magnitude for βυ This was found to be 36,075,5621 (with an eccentricity of 9165), corresponding to the entire oval path of Mars. -It was 4657.

EDIT:

Since during my task I faced wit a lot of issues have updated the question a few time.

first of all the problem is mainly solved! thank you for all for the contribution.

just a very tiny issue. based on other comments I have t integrated the solution as here

r'(?<!\S)(?<![\d,])(?:(?!(?:1[2-9]\d\d|20[01]\d|2020))\d{4,}[\u00BC-\u00BE\u2150-\u215E]?|\d{1,3}(?:,\d{3})+)(?![\d,])[\u00BC-\u00BE\u2150-\u215E]?(?!x)(?!/)

It can caputer most of the case correctly,

https://regex101.com/r/o5gdDt/8

then again as there is a kind of noise in my text like this:

" I take ψο as a figured unit [x]. It's square GEOM will also be a figured unit [x2]. Add the square GEOM on εο, 227,052, and the sum of the two will be the square GEOM of ψε or ψν. But the square GEOM of βν is 4,310,747,475 PARA "

It can not capture the number 227,052, which end with ","

when I changed it I faced with this problem

(?<!\S)(?<![\d,])(?:(?!(?:1[2-9]\d\d|20[01]\d|2020))\d{4,}[\u00BC-\u00BE\u2150-\u215E]?|\d{1,3}(?:,\d{3})+)(?![\d])[\u00BC-\u00BE\u2150-\u215E]?(?!x)(?!/) ``` (basically ignoring comma in (,?![\d])) I faced with another problem which the regex captured 4,310,747,475 in this: 4,310,747,475x2+978,763,835,536,363 as you see here.. https://regex101.com/r/o5gdDt/9 any idea would be very appreciated however the regex now works almost good, but in order to be perfect I need to improve it -

If excluding all 4 digit number years its this

`\b(?!\d{4}\b)[0-9]+(?:,(?!\d{4}\b)[0-9]+)*\b`

https://regex101.com/r/T3L3X5/1

If excluding just the number years between 1200 and 2020 its this

`\b(?!(?:12\d{2}|1[3-9]\d{2}|20[01]\d|2020)\b)[0-9]+(?:,(?!(?:12\d{2}|1[3-9]\d{2}|20[01]\d|2020)\b)[0-9]+)*\b`

https://regex101.com/r/ZuC6LR/1

**I need to write a regex that recognize all numbers with ,** I want to capture all number with comma or not comma-separated excluding 4 digit numbers: I want to match these numbers (in my case the 1 I need to write a regex that recognize all numbers with coma separated or not, excluding 4 digits numbers Oct 8 '19 1 capture the number iwth comma or dot with regex Oct 15 '19 1 My functions definition give different result when I saved as tools.py file Aug 27 '19

**Comma Number Matching,** RegEx for Matches number with commas. negate a range · money · Member PL with 4 or 5 numbers · Phone Number with Country Code · 4 digit alphanumeric Has anybody used regular expression for comma separated values ? I tried by creating various expressions, but it is not satifying all conditions. Regualr expression for comma separated numbers only. no start or end comma allowed, single comma within two numbers & single number is allowed. For e.g. - 1234123,123213213,123123,123123,123123,123123

This is matching all your test cases:

(?<![\d,])(?:(?!(?:1[2-9]\d\d|20[01]\d|2020))\d{4,}|\d{1,3}(?:,\d{3})*)(?![\d,])

**Explanation:**

(?<![\d,]) # negative lookbehind, make we haven't digit or comma before (?: # non capture group (?! # negative lookahead, make sure we haven't after: (?: # non capture group 1[2-9]\d\d # range 1200 -> 1999 | # OR 20[01]\d # range 2000 -> 2019 | # OR 2020 # 2020 ) # end group ) # end lookahead \d{4,} # 4 or more digits | # OR \d{1,3} # 1 up to 3 digits (?:,\d{3})* # non capture group, a comma and 3 digits, 0 or more times ) # end group (?![\d,]) # negative lookahead, make sure we haven't digit or comma after

**Regular Expression (Regex) Tutorial,** Getting started with regex may not be easy due to its geeky syntax, but it is certainly Character: All characters, except those having special meaning in regex, for a up to 3-digit octal number, \xhh for a two-digit hex code, \uhhhh for a 4-digit Python also uses backslash ( \ ) for escape sequences (i.e., you need to write To match all characters from 0 to 255, we’ll need a regex that matches between one and three characters. The regex [0-9] matches single-digit numbers 0 to 9. [1-9] [0-9] matches double-digit numbers 10 to 99. That’s the easy part. Matching the three-digit numbers is a little more complicated, since we need to exclude numbers 256 through 999.

**Regex numbers without commas,** I need a regular expression to allow only numerical values and comma. 1. from string with the help of a sub-string function and pattern. will match the 4. The problem I have is that the numbers in my text may or may not have decimals and Example:Match a white space, followed by one or more decimal digits, followed by How to write Regular Expressions? A regular expression (sometimes called a rational expression) is a sequence of characters that define a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. “find and replace”-like operations.(Wikipedia).

**Regex numbers without commas,** The problem I have is that the numbers in my text may or may not have decimals and commas. Regualr expression for comma separated numbers only. I think you could do just as well with non-digit matching (\D) outside of your main group. Will accept a wide variety of values that can be easy cast to a double via the What is Regular Expression? A regular expression or regex is a special text string used for describing a search pattern. Learn re module, re.match(),re.search(), re.findall(), re.split() methods in this tutorial with examples.

**Expressions in category: Numbers,** [4]{1}([0-1]{1}[0-9]{8}|[2]{1}([0-8]{1}[0-9]{7}|[9]{1}([0-3]{1}[0-9]{6}|[4]{1}([0-8]{1}[0-9]{5}|[ This regular expression validates that the data entered is a number with a d+)) # more than 3 digit with no comma separator ((? This allows a sequence of real numbers to be added, separated by a comma (required) and a The tables are not exhaustive, for two reasons. First, every regex flavor is different, and I didn't want to crowd the page with overly exotic syntax. For a full reference to the particular regex flavors you'll be using, it's always best to go straight to the source.

**Advanced Search,** I didn't want to hassel with matching all that junk, I just wanted the 10 The rules this was created by are: 1)A series of words separated by a periods 2)does not Matches dutch telephone numbers WITHOUT country code prefix Tests on mobile numbers, 3 digits prefix city-codes and 4 digit prefix city codes. Hi there, i;m having a but of trouble coming up with a regex that matches a word followed by a list of numbers seperated by a comma For example it should match word1,2,3 as well as word{1,2,3},4,5