locked
Jquery Regex to match string list separated by commas RRS feed

  • Question

  • User302996713 posted

    I need a regex to match the sample string below.

    Sample string

    "USA, "Los Angeles, California", Newyork"

    The regex below is what I have tried so far but its not working well.

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

    Kindly help me.

    Sunday, August 28, 2016 12:06 PM

All replies

  • User-1142886626 posted

    Hi Bbaale San,

    Jquery Regex to match string list separated by commas

    It seems you want use jquery regex to match string list separated by commas like the sample string. If it is your issues, you could try to put two or three regexs into one regex.

    Such as:

    /(A|B)/

    And you could write the regexs as the following. It will work fine.

    ([A-Z)]\w+\ +\w+|[0-9a-zA-Z]+(,[0-9a-zA-Z]+)*)

    Best Regards,

    Ailleen

    Monday, August 29, 2016 5:15 AM