Regular Expression for last value in comma separated list

usumoio

I am trying to build a regular expression that returns everything after the last comma in a comma separated list.

// So if my list is as followed
var tag_string = "red, green, blue";

// Then my match function would return
var last_tag = tag_string.match(A_REGEX_I_CANNOT_FIGURE_OUT_YET);

// Then in last tag I should have access to blue

// I have tried the following things: 
var last_tag = tag_string.match(",\*");

// I have seen similar solutions, but I cannot figure out how to get the only the last string after the last comma.
Jerry

You can try something like:

var last_tag = tag_string.match("[^,]+$").trim();

This will first get " blue" then remove the trailing spaces.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Regular expression to match comma separated list of key=value where value can contain html?

From Dev

Regular expression for a comma separated string

From Dev

Regular expression for a comma separated string

From Dev

Looking for a regular expression to work on a list of comma separated values

From Dev

PostgreSQL get last value in a comma separated list of values

From Dev

PostgreSQL get last value in a comma separated list of values

From Dev

Regular Expression for IP address separated by comma or *

From Dev

Check if value exists in a comma separated list

From Dev

Turn a value range in a cell into a comma separated list

From Dev

Splitting a column value into list of values separated by comma

From Dev

Find value in comma-separated list

From Dev

Find string value in comma-separated list

From Dev

Turn a value range in a cell into a comma separated list

From Dev

regular expression for multiple search in list seperated by comma

From Dev

Bash Read: Reading comma separated list, last element is missed

From Dev

Replace last comma separated value by another using regex

From Dev

Regular expression to match until last 3 characters before a comma

From Dev

How to lsearch for last matching regular expression in list

From Dev

Using Linq to find a value in comma separated value in a List

From Dev

Comma separated list in twig

From Dev

Comma separated values to List

From Dev

Mysql comma separated value

From Dev

Regular expression in PHP with comma

From Dev

Regular Expression - difficulties with comma

From Dev

Regular Expression in .net for Key Value Pairs not fully separated

From Dev

Regular Expression in .net for Key Value Pairs not fully separated

From Dev

Split comma separated string and compare each value in a List

From Dev

Splitting List<T> based on comma separated property value using Linq

From Dev

How to create comma separated list of numbers based on numeric value in column

Related Related

  1. 1

    Regular expression to match comma separated list of key=value where value can contain html?

  2. 2

    Regular expression for a comma separated string

  3. 3

    Regular expression for a comma separated string

  4. 4

    Looking for a regular expression to work on a list of comma separated values

  5. 5

    PostgreSQL get last value in a comma separated list of values

  6. 6

    PostgreSQL get last value in a comma separated list of values

  7. 7

    Regular Expression for IP address separated by comma or *

  8. 8

    Check if value exists in a comma separated list

  9. 9

    Turn a value range in a cell into a comma separated list

  10. 10

    Splitting a column value into list of values separated by comma

  11. 11

    Find value in comma-separated list

  12. 12

    Find string value in comma-separated list

  13. 13

    Turn a value range in a cell into a comma separated list

  14. 14

    regular expression for multiple search in list seperated by comma

  15. 15

    Bash Read: Reading comma separated list, last element is missed

  16. 16

    Replace last comma separated value by another using regex

  17. 17

    Regular expression to match until last 3 characters before a comma

  18. 18

    How to lsearch for last matching regular expression in list

  19. 19

    Using Linq to find a value in comma separated value in a List

  20. 20

    Comma separated list in twig

  21. 21

    Comma separated values to List

  22. 22

    Mysql comma separated value

  23. 23

    Regular expression in PHP with comma

  24. 24

    Regular Expression - difficulties with comma

  25. 25

    Regular Expression in .net for Key Value Pairs not fully separated

  26. 26

    Regular Expression in .net for Key Value Pairs not fully separated

  27. 27

    Split comma separated string and compare each value in a List

  28. 28

    Splitting List<T> based on comma separated property value using Linq

  29. 29

    How to create comma separated list of numbers based on numeric value in column

HotTag

Archive