Sounds like you need an expression like this:

^[0-9a-zA-Z]+(,[0-9a-zA-Z]+)*$

Posix allows for the more self-descriptive version:

^[[:alnum:]]+(,[[:alnum:]]+)*$
^[[:alnum:]]+([[:space:]]*,[[:space:]]*[[:alnum:]]+)*$  // allow whitespace

If you're willing to admit underscores, too, search for entire words (\w+):

^\w+(,\w+)*  // allow whitespaces around the comma
Answer from Kerrek SB on Stack Overflow
Discussions

Matching segment of comma separated string
Where are you using this? If your RegEx engine supports variable length look behinds or reset match with \K it should be possible. Here is one option: ,[^,\n]*\K\b[A-Za-z]+\b(?=.*,) Regex101 demo (Thanks for posting test data!) \K resets the match. And \b matches a word boundary to make sure we are not matching part of a post code. This assumes the post code parts always contains at least one non-letter. I can write I complete breakdown if you need it. More on reddit.com
🌐 r/regex
6
3
September 14, 2021
Regex to mach string comma separated? - PHP - SitePoint Forums | Web Development & Design Community
That’s easy A simple “match this or this or this” will work. /(ABC\.,|A\.B\.C\.,|A\.B\.,)/ · Thanks buddy BUT the values are always different and a there are some values that have 1 or 2 or 3 point separators · I mean the only sting that is constant is that it always start with a letter ... More on sitepoint.com
🌐 sitepoint.com
0
February 19, 2017
regex for comma separated string (2 strings separated by comma)
I'm not good at regex, and i'm looking for a regex solution for the below comma separated string in javascript I have a string in this format: "string1,string2" condition: 1 - Both string1... More on stackoverflow.com
🌐 stackoverflow.com
March 21, 2015
csv - Regex for Comma delimited list - Stack Overflow
What is the regular expression to validate a comma delimited list like this one: 12365, 45236, 458, 1, 99996332, ...... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Splunk Community
community.splunk.com › t5 › Splunk-Search › Help-using-regex-to-break-a-comma-separated-string › m-p › 480288
Solved: Help using regex to break a comma separated string - Splunk Community
January 5, 2021 - ... Hi , I have this regular expression - [^"\n]"\w+\s+(?P[^"]+) but when I try to do | rex field =_raw "[^"\n]"\w+\s+(?P[^"]+)" it doesn't work ... You don't have to use rex. Another way to do it is to use split to break the field at commas then use mvindex to grab the second value.
🌐
ServiceNow Community
servicenow.com › community › it-service-management-forum › regex-expression-to-check-comma-separated-string › m-p › 471369
Solved: Regex expression to check comma separated string - ServiceNow Community
February 3, 2022 - You can try other way around, below script will written false for your first two scenario and it will return true whenever there will be any special character in string. ... You can use not (!) with result to get your required output. ... Let me know if you have any further queries. Please mark this as Correct or Helpful if it helps. ... By marking my response as correct or helpful, you contribute to helping future readers with similar issues. Regards, Abhijit ServiceNow MVP ... Thank you for the response. The script which you gave didnt worked. I have used this regExp and it is working fine.
🌐
Reddit
reddit.com › r/regex › matching segment of comma separated string
r/regex on Reddit: Matching segment of comma separated string
September 14, 2021 -

Hello, I'm having troubles matching a city name when a postcode is within the string. I'm able to grab the city and the postcode correctly between the 2 commas here: https://regex101.com/r/SFkcDv/1

Data

Street, City, Country
1 Street, 123 City, United States
2 Sreet, City 12345,  United States
Block 1 Street 100, City 123456,  South Korea
120  Road,  City 068913,Country
999 Road, City HA1 1NU, United Kingdom
United States
Australia
Munich,  Germany
United States
 Philippines
Germany
USA

RegEx

(?<=,\s).+?(?=,)

However, I haven't found a way to just grab the city name without spaces and postcodes. The complexity also seems to come as UK postal codes have letters and numbers combined, in the following string:

Combwell NG17 1GQ
London L4 2UY
Manchester TS6 0SD
Hyde DH6 1NX
Oxford OX5 3HX

Any ideas on how to resolve this?

🌐
Laracasts
laracasts.com › discuss › channels › laravel › regex-for-comma-separated-string-in-validation
Regex for comma separated string in validation
If to 2 zipcodes are given, 8 digits separated by comma (without space) between and no end comma is valid like 1324,5214
🌐
Regex Tester
regextester.com › 108606
Parse Comma Separated List - Regex Tester/Debugger
Regex Tester is a tool to learn, build, & test Regular Expressions (RegEx / RegExp). Results update in real-time as you type. Roll over a match or expression for details. Save & share expressions with others. Explore the Library for help & examples. Undo & Redo with {{getCtrlKey()}}-Z / Y. Search for & rate Community patterns. ... extended (x) extra (X) single line (s) unicode (u) Ungreedy (U) Anchored (A) dup subpattern names(J) ... Url checker with or without http:// or https:// Match string not containing string Check if a string only contains numbers Only letters and numbers Match elements of a url date format (yyyy-mm-dd) Url Validation Regex | Regular Expression - Taha Match an email address Validate an ip address nginx test Extract String Between Two STRINGS special characters check match whole word Match anything enclosed by square brackets.
Find elsewhere
🌐
Regexlib
regexlib.com › Search.aspx
Search Results: 11 regular expressions found.
Regular Expression Library provides a searchable database of regular expressions. Users can add, edit, rate, and test regular expressions.
🌐
SitePoint
sitepoint.com › php
Regex to mach string comma separated? - PHP - SitePoint Forums | Web Development & Design Community
February 19, 2017 - That’s easy A simple “match this or this or this” will work. /(ABC\.,|A\.B\.C\.,|A\.B\.,)/ · Thanks buddy BUT the values are always different and a there are some values that have 1 or 2 or 3 point separators · I mean the only sting ...
🌐
regex101
regex101.com › library › cW3eA9
regex101: Capture comma separated numbers
This to validate emails in following ways The email couldn't start or finish with a dot The email shouldn't contain spaces into the string The email shouldn't contain special chars ( mailname@domain.com First group takes the first string with the name of email \$1 => (mailname) Second group takes the @ plus the domain: \$2 => (@domain) Third group takes the last part after the domain : \$3 => (.com) Submitted by https://www.linkedin.com/in/peralta-steve-atileon/ ... A neat regex for finding out whether a given torrent name is a series or a movie. Returns the full name of the series with the separator needed to make it pretty (ie, replace it with space or what you want).
🌐
Regex Tester
regextester.com › 97107
comma separated - Regex Tester/Debugger
Regex Tester is a tool to learn, build, & test Regular Expressions (RegEx / RegExp). Results update in real-time as you type. Roll over a match or expression for details. Save & share expressions with others. Explore the Library for help & examples. Undo & Redo with {{getCtrlKey()}}-Z / Y. Search for & rate Community patterns. ... extended (x) extra (X) single line (s) unicode (u) Ungreedy (U) Anchored (A) dup subpattern names(J) ... Url checker with or without http:// or https:// Match string not containing string Check if a string only contains numbers Only letters and numbers Match elements
🌐
Web Scraper
forum.webscraper.io › how to?
Parsing a comma delimited string with regex - How to? - Web Scraper
July 24, 2019 - I need to parse a text string that is comma delimited into multiple substrings, but I have no idea how to achieve this with regex. The full string looks something like this: Barwon Heads Rd, Bridgewater Crct, Carter Rd, Freshwater Dr, Wild Oak Ave, Armstrong Creek The last substring (following ...
🌐
YouTube
youtube.com › regex quickies with wiktor stribiżew
Validating strings with comma-separated values (with no leading/trailing separators) - YouTube
Validating strings with any kind of separators falls under a common scheme: "^[p](?:[sep][p])*$". This kind of pattern ensures the separator is not allowed t...
Published   August 28, 2021
Views   1K
🌐
Regex Pattern
regexpattern.com › home › regular expression to match comma separated numbers
Regular Expression To Match Comma Separated Numbers - Regex Pattern
October 27, 2022 - I hope this Regular Expression will help people who have been finding a solution for matching comma-separated values. /^\d+(,\d+)*$/ Click To Copy · 1 · 12 · 1,2,3 · 1.2.3 · a,b,c · abc · Regular Expression To Match Pipe-Delimited String · Regular Expression To Match CSV Data · Regex To Match Comma Before & After A String ·
🌐
ServiceNow Community
servicenow.com › community › itsm-forum › regex-expression-to-check-comma-separated-string › m-p › 471373
Re: Regex expression to check comma separated string
February 3, 2022 - Hi, My code should work, I have tested in my PDI. Anyway, you can add space in between '9' and ']' that will make it validate space as well. As below, I have made that part bold there is space. var regex = (/^(([a-zA-Z0-9 ](,)?)*)+$/) Let me know if you have any further queries.
🌐
Reddit
reddit.com › r/learnprogramming › [regex] help with a regex for single letters separated by comma/whitespace?
r/learnprogramming on Reddit: [Regex] Help with a regex for single letters separated by comma/whitespace?
April 9, 2021 -

My regex: ([a-zA-Z],? *)+

The desired input is something like "A, B, C, D". But of course I want to allow input where the letters aren't capitalized, or there's more than one space between a letter+comma, or no space, etc.

Here's the regex I have, but it's not quite right because input such as "A B C D" is still considered valid.

([a-zA-Z],? *)+ which as I understand it (I'm new to regex) means: contains any letter from a to z, case insensitive, followed by zero or one comma, followed by 0 or more space(s), and then 1 or more of this entire pattern.

Now the issue I think has to do with the "zero or one comma" because I want to allow the input to have multiple letters eg. "A, B, C" but the last character shouldn't be followed by a comma, because that's weird. It also needs to match with single letter input which doesn't have a comma either. So what I want is it to be like a letter followed by a comma only if this isn't the last letter or the only letter... but I don't know how to do that with regex.

EDIT: Here is a new regex I made. I think this works: ([a-zA-Z] *, *)*([a-zA-Z] *)

🌐
PerlMonks
perlmonks.org
Regular expression for a comma separated string
naderra has asked for the wisdom of the Perl Monks concerning the following question: · I would like to define a regular expression that matches strings consisting of two sub-strings separated by a single comma. Each sub-string may not be empty, and consists exclusively and without repetition ...