Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
How to find duplicate numbers between commas?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
smartscottiedog  
View profile  
 More options Oct 27, 2:03 pm
From: smartscottiedog <scottiey...@yahoo.com>
Date: Tue, 27 Oct 2009 11:03:42 -0700 (PDT)
Local: Tues, Oct 27 2009 2:03 pm
Subject: How to find duplicate numbers between commas?
I have a following regex in .NET

^(?!.*?\b44\b)(?:\s*(\d+)\s*,?)*$

This will allow comma separated list of numbers, excluding one number
I specified (e.g. 44 from above).  I would like to modify that to not
allow any duplicates numbers in the list.

For example

12, 22, 3, 45, 3, 36

should fail the validation since number 3 has been repeated.  Is that
even possible?


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eugeny.Sattler@gmail.com  
View profile  
 More options Oct 28, 4:47 am
From: "Eugeny.Satt...@gmail.com" <eugeny.satt...@gmail.com>
Date: Wed, 28 Oct 2009 01:47:06 -0700 (PDT)
Local: Wed, Oct 28 2009 4:47 am
Subject: Re: How to find duplicate numbers between commas?

> For example

> 12, 22, 3, 45, 3, 36

> should fail the validation since number 3 has been repeated.  Is that
> even possible?

I would try vice versa approach: "If a value is present twice in a
string, that string is no good" You just change logic operator in your
code. And the regex to test wether a CSV string contains duplicate
numbers would be
(\d+)[, ]+(?:\d+, )*?\1[, \r\n]+
       ^                 ^
       |__spaces here____|

So, report if that approach works.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
smartscottiedog  
View profile  
 More options Oct 28, 11:25 am
From: smartscottiedog <scottiey...@yahoo.com>
Date: Wed, 28 Oct 2009 08:25:28 -0700 (PDT)
Local: Wed, Oct 28 2009 11:25 am
Subject: Re: How to find duplicate numbers between commas?
First, thank you for replying.

I must say that I'm no good with regular expression.  The expression I
got above is from someone else and I only understand bits of it.  I
changed it as you recommended.

from

^(?!.*?\b44\b)(?:\s*(\d+)\s*,?)*$

to

^(?!.*?\b44\b)(?:(\d+)[, ]+(?:\d+, )*?\1[, \r\n]+)*$

Is this what you intended me to try out?  A complete expression string
would be great.

And thanks again.

On Oct 28, 3:47 am, "Eugeny.Satt...@gmail.com"


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eugeny.Sattler@gmail.com  
View profile  
 More options Oct 30, 6:22 am
From: "Eugeny.Satt...@gmail.com" <eugeny.satt...@gmail.com>
Date: Fri, 30 Oct 2009 03:22:32 -0700 (PDT)
Local: Fri, Oct 30 2009 6:22 am
Subject: Re: How to find duplicate numbers between commas?
Hi,
First define your goal.
If that is "not allow any duplicates numbers in the list" then i
you've got my reply already. I tested it in PowerGREP (where no code
wrapper is required at all) and it works. I hope it'll work in your
environment as well, after you wrap it into .NET specific things.

Elsewhere, if your goal is to "find a CSV line that contains "44"
value at least twice", then I would recommend the same expression as i
posted before but just change the first "\d+" to "44". Without quotes
i mean..

But why bother checking for 44 duplicates then for 569 duplicates than
for 19875624 duplicates etc. etc. etc. endlessly.... when you have a
universal solution in your hands already?
From your first message I understood that you need a universal
solution.

--
Regards,   Eugeny


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google