Splitting string in javascript using RegEx -
Trying to use RegEx to split the following string:
C = US, ST = NY, O = GOOGLE, Inc. " This objective O = GOOGLE, INC
Your data appears to be of the form of the form Will be strongly enough:
foo = bar, spic = span, a = bob \, fred
that is, the key plus = val data, With Ram, so if the saved comma data is only , then you can use a simple form for 'key =' as part of your regexp. Capitals, then it works:
s = "C = US, ST = NY, O = GOOGLE, INC" s.split (/, (? = [ i.e., split over a comma, if done after some capitals and one after the other.
This will give you
["C = US "," ST = NY "," O = GOOGLE, INC "]
Comments
Post a Comment