Reputation: 381
If I have a string in javascript like =sum(A1,B2)
or an example variation like = sum( C1, ZX2)
. The combinations of cells could be anything. I need a function to parse out the two parameters. In Javascript using regex.
Upvotes: 0
Views: 1037
Reputation: 1637
This regexp matches those strings:
\s?([A-Z]+[0-9]+).*?([A-Z]+[0-9]+)
In JavaScript you'd use this:
string.match('([A-Z]+[0-9]+).*?([A-Z]+[0-9]+)/')
It returns an array of matches, in this case it would return ["A1,A2"], you'd still need to explode the string at ','
Upvotes: 1
Reputation: 336428
/(\[A-Z]+[0-9]+)\s*,\s*(\[A-Z]+[0-9]+)/
should work on your examples. Will you also have to handle ranges like A12:C34
?
Upvotes: 1