Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6608793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:38:50+00:00 2026-05-25T19:38:50+00:00

I am using a regex to find dupliates in a list. It is only

  • 0

I am using a regex to find dupliates in a list. It is only a short comma seperated list, and performance is not an issue, so there is no need to tell me I should not use regex for those reasons.

// returns a match because some is repeated
"some,thing,here,some,whatever".match(/(^|,)(.+?)(,|,.+,)\2(,|$)/g)

Questions…

  1. Can this regex be improved?
  2. Does it cover all possible scenarios where comma is not in the seperated strings
  3. Is there a better (preferably more readable and more efficient) way to do this?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:38:51+00:00Added an answer on May 25, 2026 at 7:38 pm

    I don’t see the purpose of using regexes here, unless you like unimaginable pain. If I had to find duplicates I would

    • Obtain an array of words

      var words = "...".split(',');
      
    • optionally lowercase everything, if you feel like doing that

    • sort the array

      words.sort()
      
    • Duplicates should now all be in consecutive positions of the array.

    As an extra advantage, I`m pretty sure this would be vastly more efficient than a regex version.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to find the most optimal solution using Regex to find URL's inside
Using ICU 4.0 regex library, I find that the following regex is exhibiting exponential
Specifically, I'm using the Linux command: $ find . -regextype posix-extended -regex '<some regex>'
I'm trying to find eveything inside a div using regexp. I'm aware that there
I am using a regex to find: test:? Followed by any character until it
I'm using this regex to find <script> tags: <script (.|\n)*>(.|\n)*?</script> The problem is, it
Using Regex. I have this to find the words that end with those letters:
I am using a regex pattern to find instances of [code][/code] BB tags. (This
I am trying to find similar strings in feedback option texts using regex to
Im writing a python program using regex to find email addresses. re.findall function is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.