actionscript 3 - CSV regex with any digit -


i trying looking regex allows comma separated values. this.

  1. 23,23,23
  2. 233-2-3,23,23
  3. 23/23/2333,22-22-2222,23

i have tried couple of things nothing fits 100%.

  1. [^,;]+
  2. /(?!,)(?:(?:,|^)([-+]?(?:\d*\.)?\d+))*$/
  3. (\d+, ?)+(\d+)?

my use case , if string pass through above regex, parse values , store array. if string doesn't have single , leave string.

thanks

as stated in comments, have come following solution:

(?m)^(?:\d+[\/,-]){2,}\d+$ 

explanation:

  • (?m) : make ^ , $ match start , end of line respectively.
  • ^ : start of line
  • (?: : ignore group
    • \d+ : match digit 1 or more times
    • [\/,-] : followed / or , or -
  • ) : closing parenthesis ignore group
  • {2,} : match 2 times or more
  • \d+ : match digit 1 or more times
  • $ : end of line

online demo


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -