Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualBregma

Posted 16 September 2013 - 12:37 PM

Here's a brief, complete program that uses regex to match output all names beginning with "LS" from a vector of candidate names.  Perhaps it will help.
 
#include <iostream>
#include <regex>
#include <string>
#include <vector>

std::vector<std::string> airport_map = {
  "LSZA", "LSZB", "LSZH", "LZBB", "OMFG"
};


int
main()
{
  std::regex re("^LS");
  for (auto const& name: airport_map)
  {
    if (std::regex_search(name, re))
    {
      std::cout << name << "\n";
    }
  }
}

#1Bregma

Posted 16 September 2013 - 12:33 PM

Here's a brief, complete program that uses regex to match output all names beginning with "LS" from a vector of candidate names.  Perhaps it will help.
 
#include <iostream>
#include <regex>
#include <string>
#include <vector>

std::vector<std::string> airport_map = {
  "LSZA", "LSZB", "LSZH", "LZBB", "OMFG"
};


int
main()
{
  std::regex re("^LS");
  for (auto name: airport_map)
  {
    if (std::regex_search(name, re))
    {
      std::cout << name << "\n";
    }
  }
}

PARTNERS