I am trying to make a ruby regex t开发者_StackOverflow中文版o match tags in the format Toys, Cars, Some Other Topic but I can't figure out how to make it so that it splits it at after a comma and white space after but not if there is whitespace in a tag
This is what I have come up with http://rubular.com/r/ptjeQ1KyoD but is wrong for now.
/[\/,$\(\s+)]/
You can just use /,\s*/ (which is much simpler than what you've got!):
'Toys, Cars, Some Other Topic'.split /,\s*/
=> ["Toys", "Cars", "Some Other Topic"]
You should just use:
,\s+
This matches all commas followed by one or more whitespace characters, and doesn't match the spaces beyond Some.
You could use (/,/x) which split all strings with comma(,)
Check here
http://rubular.com/r/8XdjgLK19g
'Toys, Cars, Some Other Topic'.split(/,/x)
=> ["Toys", "Cars", "Some Other Topic"]
function Validate(txt) { txt.value = txt.value.replace(/[^, a-zA-Z]+/g, ''); }
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论