@@ -126,11 +126,27 @@ if (postcode.valid) {
126126
127127If you're just after a single value, you can import a single method.
128128
129+
130+ #### Validation
131+
129132``` javascript
130- // Validation
131133isValid (" Sw1A 2aa" ); // => true
134+ ```
135+
136+ #### Formatting
137+
138+ ```
139+ import {
140+ toNormalised,
141+ toOutcode,
142+ toIncode,
143+ toArea,
144+ toDistrict,
145+ toSubDistrict,
146+ toSector,
147+ toUnit,
148+ } from "postcode";
132149
133- // Formatting
134150toNormalised("Sw1A 2aa"); // => "SW1A 2AA"
135151toOutcode("Sw1A 2aa"); // => "SW1A"
136152toIncode("Sw1A 2aa"); // => "2AA"
@@ -140,25 +156,33 @@ toSubDistrict("Sw1A 2aa"); // => "SW1A"
140156toSector("Sw1A 2aa"); // => "SW1A 2"
141157toUnit("Sw1A 2aa"); // => "AA"
142158
143- // Match
144- // Retrieve valid postcodes in a body of text
159+ #### Extract & Replace
160+
161+ `match`. Retrieve valid postcodes in a body of text
162+
163+ ```javascript
145164const matches = match("The PM and her no.2 live at SW1A2aa and SW1A 2AB"); // => ["SW1A2aa", "SW1A 2AB"]
146165
147166// Perform transformations like normalisation postcodes using `.map` and `toNormalised`
148167matches.map(toNormalised); // => ["SW1A 2AA", "SW1A 2AB"]
149168
150169// No matches yields empty array
151170match("Some London outward codes are SW1A, NW1 and E1"); // => []
171+ ```
172+
173+ ` replace ` . Replace postcodes in a body of text, returning the updated corpus and any matching postcodes
152174
153- // Replace
154- // Replace postcodes in a body of text
155- replace ( " The PM and her no.2 live at SW1A2AA and SW1A 2AB " ); // => { match: ["SW1A2AA", "SW1A 2AB"], result: "The PM and her no.2 live at and " }
175+ ``` javascript
176+ replace ( " The PM and her no.2 live at SW1A2AA and SW1A 2AB " );
177+ // => { match: ["SW1A2AA", "SW1A 2AB"], result: "The PM and her no.2 live at and " }
156178
157179// Add custom replacement
158- replace (" The PM lives at SW1A 2AA" , " Downing Street" ); // => { match: ["SW1A 2AA"], result: "The PM lives at Downing Street" };
180+ replace (" The PM lives at SW1A 2AA" , " Downing Street" );
181+ // => { match: ["SW1A 2AA"], result: "The PM lives at Downing Street" };
159182
160183// No match
161- replace (" Some London outward codes are SW1A, NW1 and E1" ); // => { match: [], result: "Some London outward codes are SW1A, NW1 and E1" }
184+ replace (" Some London outward codes are SW1A, NW1 and E1" );
185+ // => { match: [], result: "Some London outward codes are SW1A, NW1 and E1" }
162186```
163187
164188## Version 5.0.0
0 commit comments