Hi,
You need to use some kind of rule for those addresses. The text gatherers will let you break the text into words, but if you do this, the gatherer will extract only one word. If you need to extract a section, try using the project attached. Import it into your current project, then go to
Project -> JavaScript Gatherers and see the
JS_Section gatherer. Note the first 3 lines of code. The
separator is the character that you'll use to break the text into sections, the
start will be the index of the first section and the
end will be the index of the last section, where the first index is zero. If you use negative numbers on any of these last two variables, it will start counting from the last section and go backwards. Finally, if you want to go from any section to the last section, set the
end variable to
undefined (code would look like this:
var end = undefined;).
Here is an example, say you want to extract the last two words from this text: "4900 Bathurst Toronto ON M2R 1X6" (which would give you "M2R 1X6"). To do this, you'd set
start to -2 and
end to
undefined, like this:
Code: Select all
var separator = " ";
var start = -2;
var end = undefined;
If you want to extract the word "ON" from the text above you could do it by setting
start to -3 and the
end to -2 (you'd get the same result on this particular text by setting the
start to 3 and the
end to 4, but you'd be counting from the beginning instead of from the end, and street addresses can have different amount of words, but seems like zip codes always have two words). To extract everything before province (ON), you'd set
start to 0 and
end to -3.
Remember that you can preview what any gatherer will extract by clicking on the Choose visible properties button in the selection panel at the bottom and checking whatever gatherer you want to preview under the Selection Preview panel (in this case, choose JS_Sections) and then selecting whatever elements you want to preview it for with selection mode on. Also, note that you can copy this whole code and paste it into a new JavaScript gatherer to use more than one section on your project.