Answers.Body: <p>It's true - <a href="https://github.com/civicrm/civicrm-core/blob/master/CRM/Contact/Form/Search/Builder.php#L291" rel="noreferrer">looking at the code</a>, I can see that Search Builder expects an integer if you're searching on an integer field.  An exception is made for using the <code>IN</code> operator, in which case it validates each value separately.</p>
  
  <p>Trying to validate a regex to ensure it's non-malicious is a very difficult task, and I think the appropriate answer is to remove the regex function from the Search Builder on integers.  Work is being done on Civi 5.2 to remove operators from Search Builder that aren't appropriate.</p>
  
  <p>However, to solve YOUR problem, you should use <code>IN</code>, separating your values by commas like so: <code>64,5917,5725,5892,5852,5818,5893,5850</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T18:25:58.127Z
Answers.LastActivityDate: 2018-05-11T18:25:58.127Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>Adding to the Suggestion of Jon G there is a simple extension to SearchBuilder that allows to paste ContactIDs into a separate field and converts those to an 'IN' query with comma separated values: <a href="https://github.com/bhahumanists/bha.searchbuilder" rel="nofollow noreferrer">https://github.com/bhahumanists/bha.searchbuilder</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-14T15:12:01.503Z
Answers.Text: Thanks to JonG for the background and a simple solution. I'm choosing this as my answer because it avoids the step of concatenating the list with comma deliminators.
Answers.UserDisplayName: Phil Morice Brubaker
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-14T12:41:07.937Z
Answers.LastActivityDate: 2018-05-14T12:41:07.937Z
Answers.UserDisplayName: Thomas Schüttler
Body: <p>I occasionally have a list of contacts outside of Civi but with CiviIDs that I want to search for in Civi, but aren't grouped in any easily accessible way (no common event, activity, tag, group, etc. to search for). If it were a longer list, I'd do an update import on the contacts (with no actual changes) adding them to a new temporary group. But if I have fewer than say 10, that seems like a lot of steps.</p>
  
  <p>I thought, "A regex search builder would work." But when I put</p>
  
  <pre><code>\b(64|5917|5725|5892|5852|5818|5893|5850)\b
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>\b64\b
  </code></pre>
  
  <p>OR even</p>
  
  <pre><code>[64]
  </code></pre>
  
  <p>into the regex search, I get a "Please enter a valid value" error. I seem to get a valid search when using only numeric text ("64") without any regex operators, which kind of defeats the entire purpose of regex.</p>
  
  <p>I'm not a big regex user, so I could believe I've screwed up the regex. Anything I'm doing wrong here?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-11T19:22:02.807Z
Comments.Text: Depending on how big your list is, you could just import the IDs, and add to New Group as part of the import, then click on Group and you have your search output.
Comments.UserDisplayName: petednz - fuzion
Tags: <search-builder>
Title: Regex search for a list of Contact IDs
ThreadText: # Regex search for a list of Contact IDs
  
  (Asked by: username_0 on 2018-05-11)
  
  I occasionally have a list of contacts outside of Civi but with CiviIDs that I want to search for in Civi, but aren't grouped in any easily accessible way (no common event, activity, tag, group, etc. to search for). If it were a longer list, I'd do an update import on the contacts (with no actual changes) adding them to a new temporary group. But if I have fewer than say 10, that seems like a lot of steps.
  I thought, "A regex search builder would work." But when I put
  \b(64|5917|5725|5892|5852|5818|5893|5850)\b
  
  OR
  \b64\b
  
  OR even
  [64]
  
  into the regex search, I get a "Please enter a valid value" error. I seem to get a valid search when using only numeric text ("64") without any regex operators, which kind of defeats the entire purpose of regex.
  I'm not a big regex user, so I could believe I've screwed up the regex. Anything I'm doing wrong here?
  
  **Tags:** search-builder
  
  > **Comments:**
  > **username_1**: Depending on how big your list is, you could just import the IDs, and add to New Group as part of the import, then click on Group and you have your search output.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2018-05-14. Score: 4 | Accepted answer
  
  Adding to the Suggestion of Jon G there is a simple extension to SearchBuilder that allows to paste ContactIDs into a separate field and converts those to an 'IN' query with comma separated values: <https://github.com/bhahumanists/bha.searchbuilder>
  
  > **Comments:**
  > **username_0**: Thanks to JonG for the background and a simple solution. I'm choosing this as my answer because it avoids the step of concatenating the list with comma deliminators.  
  
  ---
  
  ### Answer by username_2 on 2018-05-11. Score: 7
  
  It's true - [looking at the code](https://github.com/civicrm/civicrm-core/blob/master/CRM/Contact/Form/Search/Builder.php#L291), I can see that Search Builder expects an integer if you're searching on an integer field. An exception is made for using the `IN` operator, in which case it validates each value separately.
  
  Trying to validate a regex to ensure it's non-malicious is a very difficult task, and I think the appropriate answer is to remove the regex function from the Search Builder on integers. Work is being done on Civi 5.2 to remove operators from Search Builder that aren't appropriate.
  
  However, to solve YOUR problem, you should use `IN`, separating your values by commas like so: `64,5917,5725,5892,5852,5818,5893,5850`
  
  
  ---
  
  