<reponame>boneyag/msr-2022<filename>dataPreparation/data/json_files/33847920.json
{"tags": ["regex", "apex"], "comments": [{"score": 1, "creation_date": 1448136051, "post_id": 33847920, "comment_id": 55460490, "body": "Depending on what you are going to do with those numbers in the string and how many there are of them, there may be better ways."}, {"score": 3, "creation_date": 1448136149, "post_id": 33847920, "comment_id": 55460525, "body": "Regex isn&#39;t the best tool for stuffs like this. Split the string at the comma and then select for distinct values."}, {"score": 0, "creation_date": 1448136188, "post_id": 33847920, "comment_id": 55460544, "body": "they occur any number of times, i just want to remove the duplicate numbers."}, {"score": 1, "creation_date": 1448136459, "post_id": 33847920, "comment_id": 55460637, "body": "What programming environment will you use ? A regex pattern only allows for detection, but you want to transform the string."}, {"score": 0, "creation_date": 1448136603, "post_id": 33847920, "comment_id": 55460691, "body": "i will use apex.......can we avoid duplicates using regex????"}, {"score": 0, "creation_date": 1448137129, "post_id": 33847920, "comment_id": 55460885, "body": "Is that APEX, as in Oracle Application Express, or Apex, as in salesforce.com?"}, {"score": 0, "creation_date": 1448137319, "post_id": 33847920, "comment_id": 55460951, "body": "If you are writing that in a normal programming environment, just split with comma and remove dupes. No need in regex."}], "answers": [{"score": 1, "last_activity_date": 1448136582, "answer_id": 33848074, "question_id": 33847920, "body": "<p>If all you have are numbers, this might work.<br>\n<em>This doesn't address the viability of integers though, just characters.</em>  </p>\n\n<p><code>\\b(\\d+)(?=.*?\\1\\b)\\b</code>  </p>\n\n<p>Using a backreference, it matches if a number exists downstream using a lookahead.  </p>\n\n<p><code>\\b(\\d+)(?=.*?\\b\\1\\b)\\b</code>  </p>\n\n<p>Replace with nothing.  </p>\n\n<p>Formatted:  </p>\n\n<pre><code> \\b \n ( \\d+ )                       # (1)\n (?= .*? \\b \\1 \\b )\n \\b\n</code></pre>\n"}], "is_answered": true, "answer_count": 1, "score": 0, "last_activity_date": 1448304179, "creation_date": 1448135723, "question_id": 33847920, "title": "Regular expression to avoid duplicate numbers separated by comma", "body": "<p>I have a string like <code>622,645,677,622,689,673,622</code>.</p>\n\n<p>I want to remove the duplicates from the above string.</p>\n\n<p>I have tried with <code>(\\d{3},)*</code> but the duplicates were not detected.</p>\n\n<p>How should I modify the expression to avoid duplicates?</p>\n"}