File: cnttp.cpp

package info (click to toggle)
ctre 3.9.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,084 kB
  • sloc: cpp: 80,452; makefile: 135; javascript: 69; python: 31
file content (22 lines) | stat: -rw-r--r-- 512 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <ctre.hpp>
#include <string_view>

struct name { bool has; std::string_view first, family; };

name extract(std::string_view sv) noexcept {
	#if CTRE_CNTTP_COMPILER_CHECK
	if (auto [re,f,l] = ctre::match<"([A-Za-z]+?),([A-Za-z]+?)">(sv); re) {
	#else
	using namespace ctre::literals;
	if (auto [re,f,l] = "([A-Za-z]+?),([A-Za-z]+?)"_ctre.match(sv); re) {
	#endif
		return name{true, f,l};
	} else {
		return name{false, std::string_view(), std::string_view()};
	}
}

int main() {
	
}