You almost have it, you just left out 0 and forgot the quantifier.

word.matches("^[0-9,;]+$")
Answer from Anomie on Stack Overflow
🌐
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.
Discussions

[Regex] Help with a regex for single letters separated by comma/whitespace?
One option is to use a term to match letters which include a comma, and a final term having no comma. That would look like: ([a-zA-Z],\s*)*[a-zA-Z] This pattern forces the presence of at least one letter. You didn't mention which regex syntax you're using, so I've taken some liberties (\s is a class of all whitespace characters). It might be possible to reduce this further using a negative lookahead assertion (if supported), but like I said.. I don't know which engine you're using. *edit: in case [a-Z] wasn't obvious. More on reddit.com
🌐 r/learnprogramming
5
1
April 9, 2021
Regex to check if string has special characters except dash and comma and split
If string contains special character like hello-world but not dash(/) and comma (,) then split get the string output which is input: hello-world output : world input : hi,hello output: hi,hello input : my-friend output: friend Thanks More on forum.uipath.com
🌐 forum.uipath.com
5
0
September 30, 2020
RegexMatcher for Special Characters
I want to identify if there are any invalid characters in my records. Only below special characters are valid "[a-zA-Z][0-9]^_=!#$%&()*+,-.:'/?@ ") If any other special character appears other than above, it needs to say false. Eg: In the above special characters, there is no “|,~”. If ... More on forum.knime.com
🌐 forum.knime.com
1
0
October 6, 2023
how to match all special characters except a comma
What's the regex values for to match a string against all special characters and letters except a comma. value = "23,$�"; I want to do a match if the value has any pf the special characters and More on stackoverflow.com
🌐 stackoverflow.com
🌐
RegExr
regexr.com › 3da8k
RegExr: Learn, Build, & Test RegEx
period or comma · Fork (ctrl-s) New · by gskinner · GitHub · Sign In · Pattern Settings · My Patterns · Cheatsheet · RegEx Reference · Community Patterns · Help · RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp).
🌐
Notepad++ Community
community.notepad-plus-plus.org › topic › 25553 › regexp-to-match-comma-s-end-of-line
regexp to match comma(s) end of line | Notepad++ Community
March 9, 2024 - So it find ends of lines that have only combinations of spaces and commas. ... It uses \s, so if you want to use only spaces, you need to replace this with the correct symbol. ... I’d slightly modify Ekopalypse’s proposed regex to (?:\h*,+\h*)+$. It’s the same thing, except it doesn’t consume empty lines.
🌐
SiteSpect
doc.sitespect.com › knowledge › using-regular-expressions-in-sitespect
Using Regular Expressions (regex) in SiteSpect
In regex, there are basically two types of characters: Regular characters, or literal characters, which means that the character is what it looks like. The letter "a" is simply the letter "a". A comma "," is simply a comma and has no special meaning.
🌐
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] *)

🌐
Regexsonline
regexsonline.com › how-to-find-a-comma-using-regular-expression-in-c
Finding a Comma Using Regular Expression in C | Regexsonline.com
December 24, 2022 - In C#, you can use the Regex class’ Replace() method to replace commas in a string with other characters. You need to pass the regex expression “,” to the Regex class constructor and then call the Replace() method. You have to pass the input string in which you want to replace commas, ...
🌐
UiPath Community
forum.uipath.com › help › studio
Regex to check if string has special characters except dash and comma and split - Studio - UiPath Community Forum
September 30, 2020 - If string contains special character like hello-world but not dash(/) and comma (,) then split get the string output which is input: hello-world output : world input : hi,hello output: hi,hello input : my-friend o…
Find elsewhere
🌐
SAS Support Communities
communities.sas.com › t5 › SAS-Programming › Regular-expressions-match-dot-and-comma-as-characters › td-p › 780503
Solved: Regular expressions: match dot and comma as characters - SAS Support Communities
November 17, 2021 - \b) cannot occur directly after a comma or a period because by definition it is "the position between a word and a space" -- but neither the comma nor the period is a word character (cf. PRX metacharacter · \w). The " \x" in your regular expression should read " |x". Try this regex instead: a=prxchange('s/\b(x\.,|x\.|x\b)//i', -1, name); 2 Likes ·
🌐
Stack Overflow
stackoverflow.com › questions › 56024726 › regex-for-special-characters-and-decimals-except-for-commas
string - RegEx for special characters and decimals except for commas - Stack Overflow
Regex testing for special characters, decimal except for hyphen, commas, alpha-numeric. Attempt ^(\+|-)?([0-9]+)$/ I'm trying to write a regex to match special characters, decimal except for comma...
🌐
Reddit
reddit.com › r/programming › the regex comma dash dot [,-.]
r/programming on Reddit: The regex comma dash dot [,-.]
July 3, 2022 - Regexp’s have specific rules for handing their own metacharacters (‘[’, ‘]’, ‘-’, etc.). Hyphen/dash must always be handled specially - every implementation I’ve seen will allow it as the first character (which also nicely calls attention to it being a special case in the code), and some implementations will allow it as last, or to be escaped with backslash.
🌐
Regex Tester
regextester.com › 95468
Comma and Slash - Regex Tester/Debugger
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 Url Validation Regex | Regular Expression - Taha Match an email address Validate an ip address nginx test match whole word Match or Validate phone number Match html tag Find Substring within a string that begins and ends with paranthesis Match dates (M/D/YY, M/D/YYY, MM/DD/YY, MM/DD/YYYY) Blocking site with unblocked games Empty String Match if doesn't start with string Checks the length of number and not starts with 0 Match a valid hostname Not Allowing Special Characters · Regex Tester isn't optimized for mobile devices yet.
🌐
Super User
superuser.com › questions › 1495901 › replace-sub-string-with-last-special-character-being-3rd-part-of-comma-separa
regex - replace sub-string with last special character, being (3rd part) of comma separated string - Super User
October 25, 2019 - As you can see, the 3rd comma separated value has sometimes special character, like the dash (-), in the end. I want to used sed, or preferably perl command to replace this string (with the -i option, so as to replace at existing file), with ...
🌐
ServiceNow Community
servicenow.com › community › itsm-forum › regex-expression-to-check-comma-separated-string › m-p › 471373
Solved: Re: Regex expression to check comma separated stri... - ServiceNow Community
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/regex › [question] extract single digit/character before last symbol/special character
r/regex on Reddit: [QUESTION] Extract single digit/character before last symbol/special character
December 21, 2020 -

Many thanks in advance if you can spare a quick second with this seemingly simple puzzle.

I have the following strings and need to extract 2nd to last digit/digit before the last comma. I've tried dozens of different attempts but it appears this one is beyond me so happy to learn from the correct regex with the aim of being able to pass the knowledge on. As this is within a webapp, I suspect the engine being used will very likely be Javascript.

INPUTS:

0, 2, 3
1, 3, 6, 8
8, 4
9, 3, 5, 3, 7

DESIRED OUTPUTS:

2

6

8

3

SOME NAIVE ATTEMPTS:

(?<=\d+)([A-Z]{1})$

([0-9]*)+([A-Z]*)

([0-9]+)([A-Z])

Huge thanks once again if you can help as I've been pulling my hair out for ages!

Warmest regards.

Top answer
1 of 4
4
There are several ways to do this, either with a capture group. Or a look-ahead if you just want the number alone in the match: (\d), \d$ This captures the digit in the example you posted. If you want a more general solution for “extract character before the last symbol” you would do something like this: (\w),[^,\n]*$ In both cases you can use a look-ahead if you don’t want to use a capture group, like so: \w(?=,[^,\n]*$) RegEx 101 demo The RegEx works like so: (\w), Match a letter or digit followed by a comma [^,\n]*$ Match anything that is not a comma or new line, zero ore more times, until the end of the line. Hope that works for you.
2 of 4
3
Thank you SO SO much for spending the time to teach me! I'm extremely apologetic as I got things slightly wrong regarding what the program I'm using is capable of! It turns out, it only has a replace/replace all function so to achieve my 'desired output' from above, instead of 'extracting,' I actually need to replace everything else with 'nothing' (i.e. blanks) leaving just the 2nd to last digit/digit before the last comma: Field(string) contains: 9, 3, 5, 3, 7 What I need to type in: replace( "string", "regex", "blank") Desired output: 3 Now I'm not sure if that is even possible with regex - I feel like my head is going to explode but learn best from deconstructing expressions from those that know so would be deeply grateful if you could spare a few more seconds to come up with any expressions if you think this is possible. Huge thanks once again you lovely people! cc: u/deltini , u/Pauley0 , u/BarneField
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Regular_expressions › Cheatsheet
Regular expression syntax cheat sheet - JavaScript | MDN
This page provides an overall cheat sheet of all the capabilities of RegExp syntax by aggregating the content of the articles in the RegExp guide. If you need more information on a specific topic, please follow the link on the corresponding heading to access the full article or head to the guide. Character classes distinguish kinds of characters such as, for example, distinguishing between letters and digits.