You are here

protected function InstagramPostsObtainedSubscriber::parseHashTags in Instagram Feeds 8

Parses hash tags from string.

Parameters

string $caption:

Return value

string[] An array of Instagram hash tags.

1 call to InstagramPostsObtainedSubscriber::parseHashTags()
InstagramPostsObtainedSubscriber::onInstagramPostsObtained in src/EventSubscriber/InstagramPostsObtainedSubscriber.php
Reacts on posts obtained event.

File

src/EventSubscriber/InstagramPostsObtainedSubscriber.php, line 146

Class

InstagramPostsObtainedSubscriber
Subscriber to InstagramPostsObtainedEvent event.

Namespace

Drupal\instagram_feeds\EventSubscriber

Code

protected function parseHashTags($caption) : array {
  $tags = [];
  preg_match_all('~(#\\w+)~', $caption, $tags, PREG_PATTERN_ORDER);
  return $tags[1] ?: [];
}