Function egg_mode_text::entities
[−]
[src]
pub fn entities(text: &str) -> Vec<Entity>
Parses the given string for all entities: URLs, hashtags, financial symbols ("cashtags"), user mentions, and list mentions.
This function is a shorthand for calling url_entities
, mention_list_entities
,
hashtag_entities
, and symbol_entities
before merging the results together into a single Vec.
The output is sorted so that entities are in that order (and individual kinds are ordered
according to their appearance within the string) before exiting.
Example
use egg_mode_text::{EntityKind, entities}; let text = "sample #text with a link to twitter.com"; let mut results = entities(text).into_iter(); let entity = results.next().unwrap(); assert_eq!(entity.kind, EntityKind::Url); assert_eq!(entity.substr(text), "twitter.com"); let entity = results.next().unwrap(); assert_eq!(entity.kind, EntityKind::Hashtag); assert_eq!(entity.substr(text), "#text"); assert_eq!(results.next(), None);