Skip to content

Commit 4601795

Browse files
authored
Update README.md
Add example of using the parse() method
1 parent 31ec059 commit 4601795

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,25 @@ autolinker.link( "Go to www.google.com" );
266266
267267
```
268268

269+
## Retrieving the List of Matches
270+
271+
If you're just interested in retrieving the list of [Matches](http://greg-jacobs.com/Autolinker.js/api/#!/api/Autolinker.match.Match) without producing a transformed string, you can use the [parse()](http://greg-jacobs.com/Autolinker.js/api/#!/api/Autolinker-static-method-parse) method.
272+
273+
For example:
274+
275+
```
276+
var matches = Autolinker.parse( "Hello google.com, I am asdf@asdf.com", {
277+
urls: true,
278+
email: true
279+
} );
280+
281+
console.log( matches.length ); // 2
282+
console.log( matches[ 0 ].getType() ); // 'url'
283+
console.log( matches[ 0 ].getUrl() ); // 'google.com'
284+
console.log( matches[ 1 ].getType() ); // 'email'
285+
console.log( matches[ 1 ].getEmail() ); // 'asdf@asdf.com'
286+
```
287+
269288
270289
## Custom Replacement Function
271290

0 commit comments

Comments
 (0)