Function egg_mode_text::symbol_entities [] [src]

pub fn symbol_entities(text: &str, check_url_overlap: bool) -> Vec<Entity>

Parses the given string for financial symbols ("cashtags"), optionally leaving out those that are part of URLs.

The entities returned by this function can be used to find symbols for hyperlinking, as well as to provide an autocompletion facility, if the byte-offset position of the cursor is known with relation to the full text.

The check_url_overlap parameter behaves the same way as in hashtag_entities; when true, it will parse URLs from the text first and check symbols to make sure they don't overlap with any extracted URLs.

Example

use egg_mode_text::symbol_entities;

 let text = "some $stock symbol";
 let mut results = symbol_entities(text, true).into_iter();

 let tag = results.next().unwrap();
 assert_eq!(tag.substr(text), "$stock");

 assert_eq!(results.next(), None);