parsePlace function

List<String> parsePlace(
  1. String stringReference
)

Finds all the places within a string. Returns an empty list when no places are found.

parsePlace('I visited Jerusalem and Damascus.');

Returns a list of matched places.

Implementation

/// list when no places are found.
  ///
  /// ```dart
  /// parsePlace('I visited Jerusalem and Damascus.');
  /// ```
  /// Returns a list of matched places.
   List<String> parsePlace(String stringReference) {
    var matchedPlaces = <String>[];
    var normalizedString = stringReference.toLowerCase();
    PlaceData.places.forEach((place) {
      if (normalizedString.contains(place.toLowerCase())) {
        matchedPlaces.add(place);
      }
    });
    return matchedPlaces;
  }