当前位置: 首页>>代码示例>>C++>>正文


C++ regex_match函数代码示例

本文整理汇总了C++中regex_match函数的典型用法代码示例。如果您正苦于以下问题:C++ regex_match函数的具体用法?C++ regex_match怎么用?C++ regex_match使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了regex_match函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: clearenv_

  void
  clearenv_(const std::string& regular_expression)
  {
    regex re (regular_expression);
    cmatch var;

    char **p = environ;
    while (p && *p)
      {
        if (regex_match (*p, var, re))
          {
            unsetenv (var[1]);
          }
        ++p;
      }
  }
开发者ID:sirjaren,项目名称:utsushi,代码行数:16,代码来源:environment.hpp

示例2: ifs

bool Object::Parse(string filename)
{
	ifstream ifs(filename);
	if(!ifs)
		return false;

	regex row[6] = 
	{
		regex("BEGFILE$"),
		regex("OBJNAME (\\w+)$"),
		regex("FILENAME (.+)$"),
		regex("PTS (\\d+)$"),
		regex("DMG (\\d+)$"),
		regex("ENDFILE$")
	};
	
	smatch match;
	string in;

	getline(ifs, in);
	if(!regex_match(in, match, row[0]))
		return false;


	getline(ifs, in);
	if(!regex_match(in, match, row[1]))
		return false;
	else
		name = match[1]; 
	

	getline(ifs, in);
	if(!regex_match(in, match, row[2]))
		return false;
	else
		graphfile = match[1];   

	getline(ifs, in);
	if(!regex_match(in, match, row[3]))
		return false;
	else
		points = from_string<int>(match[1]);

	getline(ifs, in);
	if(!regex_match(in, match, row[4]))
		return false;
	else
		damage = from_string<int>(match[1]);

	getline(ifs, in);
	if(!regex_match(in, match, row[5]))
		return false;

	return true;
}
开发者ID:kubawal,项目名称:Samolocik,代码行数:55,代码来源:Object.cpp

示例3: e

//-----------------------------------------------------------------------------------------
void OgitorsRoot::GetObjectListByCustomProperty(unsigned int type, const Ogre::String& nameregexp, bool inverse, ObjectVector& list)
{
    list.clear();

    try
    {
        const boost::regex e(nameregexp.c_str());

        NameObjectPairList::iterator list_st, list_ed;

        if(type == 0)
        {
            list_st = mNameList.begin();
            list_ed = mNameList.end();
        }
        else
        {
            list_st = mNamesByType[type].begin();
            list_ed = mNamesByType[type].end();
        }

        OgitorsPropertyVector pvec;

        while(list_st != list_ed)
        {
            pvec = list_st->second->getCustomProperties()->getPropertyVector();
            bool add_list = false;
            for(unsigned int k = 0;k < pvec.size();k++)
            {
                if(regex_match(pvec[k]->getName().c_str(), e))
                {
                    add_list = true;
                    break;
                }
            }
            
            if(add_list != inverse)
                list.push_back(list_st->second);
            
            list_st++;
        }
    }
    catch(...)
    {
        list.clear();
    }
}
开发者ID:EternalWind,项目名称:Ogitor-Facade,代码行数:48,代码来源:OgitorsRootRegExp.cpp

示例4: while

bool ClienteDeNotificaciones::inicializar	(	const std::string& rutaFicheroServidores,
												const std::string& rutaFicheroFiltro,
												const std::string& rutaFicheroHistorial,
												int tiempoExpiracionNotificaciones,
												bool mostrarRutaCompletaNotificaciones,
												bool mostrarRemitenteNotificaciones,
												int numeroSesionesAntiguas )
{
	//Se inicializa el notificador; en caso de problemas, se retorna false
	if (!notificador_.inicializar(nombre_de_aplicacion_, rutaFicheroFiltro)) return false;
	
	//Se configura el notificador con en base a los parámetros recibidos
	notificador_.establecer_tiempo_visible(tiempoExpiracionNotificaciones);
	notificador_.establecer_mostrar_ruta_completa(mostrarRutaCompletaNotificaciones);
	notificador_.establecer_anadir_remitente(mostrarRemitenteNotificaciones);
	notificador_.establecer_numero_de_historiales_antiguos(numeroSesionesAntiguas);
	notificador_.establecer_historial_de_sesion(rutaFicheroHistorial);
	
	//Se parsea el fichero de servidores, conectando a cada uno de los especificados
	ifstream fichero_servidores;
	fichero_servidores.open(rutaFicheroServidores);
	if (!fichero_servidores.is_open()) return false;
	
	string linea = "";
	string direccion = "";
	string puerto = "";
	while (getline(fichero_servidores, linea))
	{
		//if (regex_match(linea, regex("[.]+/[\\d]+")))
		if (regex_match(linea, regex("[^/]+/[\\d]+")))
		{
			direccion = linea.substr(0, linea.find_first_of('/'));
			puerto = linea.substr(linea.find_first_of('/') + 1, string::npos);
			conectarServidor(anadirServidor(direccion, puerto));
			
		}
		
	}
	fichero_servidores.close();
	
	//Si la lista de proveedores está vacía, se retorna error para informar de que ha habido algún problema
	if (proveedores_.empty()) return false;
	
	//Se espera a que no quede ningún Servidor activo para finalizar
	for (unsigned int i = 0; i < proveedores_.size(); ++i) proveedores_[i].esperar();
	return true;
}
开发者ID:guillermofarina,项目名称:lognotify,代码行数:47,代码来源:cliente_de_notificaciones.cpp

示例5: r1

/** @brief (validate operation field with regex)
  * match operand with different operand regexes and extract operand from string
  * if does not match make operand field empty and generate error message
  */
bool InputReader::validateOperand() {
    if(autalities::tolow(operation) == "word"){
        autalities::removeTrailingSpaces(operand);
        return true;
    }
    smatch sm;
    regex r1("[xX]\'[a-fA-F0-9]+\'\\s*", regex_constants::ECMAScript);
    regex r2("[cC]\'(\\w|\\W)+\'\\s*", regex_constants::ECMAScript);
    if(regex_match(operand, r1) || regex_match(operand, r2)) {
        autalities::removeTrailingSpaces(operand);
        return true;
    } else if (regex_match(operand, sm, OPERAND_REGEX)) {
        autalities::removeTrailingSpaces(operand);
        return true;
    } else if (regex_match(operand, sm, IMMEDIATE_INDIRECT_REGEX)) {
        autalities::removeTrailingSpaces(operand);
        return true;
    } else if (regex_match(operand, sm, TWO_OPERANDS_REGEX)) {
        autalities::removeTrailingSpaces(operand);
        return true;
    } else if (regex_match(operand, sm, LITERAL_CHAR_REGEX)) {
        autalities::removeTrailingSpaces(operand);
        return true;
    } else if(regex_match(operand, sm, LITERAL_HEX_REGEX)) {
        autalities::removeTrailingSpaces(operand);
        return true;
    } else if(regex_match(operand, sm, INDEXING_REGEX)) {
        autalities::removeTrailingSpaces(operand);
        return true;
    } else if(regex_match(operand , sm, IS_HEX_REGEX)){
        autalities::removeTrailingSpaces(operand);
        return true;
    }
    operand = "";
    valid = false;
    addToErrorMessage("wrong format operand field");
    //cout << operand << "\n";
    return false;
}
开发者ID:mohamedramadan2515,项目名称:sicassembler,代码行数:43,代码来源:InputReader.cpp

示例6: nfs3_call

void
nfs3_call(u_int32_t xid, u_int32_t proc, u_char *buf, int len)
{
	XDR xdrs;
	struct LOOKUP3args largs;
	struct READ3args rargs;
	struct myreadargs *ma;
	char *fname;
	
	switch (proc) {
		
	case NFSPROC3_LOOKUP:
		memset(&largs, 0, sizeof(largs));
		xdrmem_create(&xdrs, buf, len, XDR_DECODE);
		
		if (xdr_LOOKUP3args(&xdrs, &largs)) {
			if (regex_match(largs.what.name)) {
				xid_map_enter(xid, NFS_PROGRAM, NFS_V3,
					      proc, (void *)largs.what.name);
			}
		}
		xdr_destroy(&xdrs);
		break;
		
	case NFSPROC3_READ:
		memset(&rargs, 0, sizeof(rargs));
		xdrmem_create(&xdrs, buf, len, XDR_DECODE);
		
		if (xdr_READ3args(&xdrs, &rargs)) {
			fname = fh_map_find(rargs.file.data.data_val,
					    rargs.file.data.data_len);
			if (fname != NULL) {
				ma = (struct myreadargs *) malloc(sizeof(*ma));
				if (ma != NULL) {
					ma->filename = fname;
					ma->offset = rargs.offset;
					xid_map_enter(xid, NFS_PROGRAM, NFS_V3,
						      NFSPROC_READ,
						      (void *)ma);
				}
			}
		}
		xdr_destroy(&xdrs);
		break;
	}
}
开发者ID:IFGHou,项目名称:dsniff,代码行数:46,代码来源:filesnarf.c

示例7: nfs2_call

void
nfs2_call(u_int32_t xid, u_int32_t proc, u_char *buf, int len)
{
	XDR xdrs;
	struct diropargs dargs;
	struct readargs rargs;
	struct myreadargs *ma;
	char *fname;
	
	switch (proc) {
		
	case NFSPROC_LOOKUP:
		memset(&dargs, 0, sizeof(dargs));
		xdrmem_create(&xdrs, buf, len, XDR_DECODE);
		
		if (xdr_diropargs(&xdrs, &dargs)) {
			if (regex_match(dargs.name)) {
				xid_map_enter(xid, NFS_PROGRAM, NFS_VERSION,
					      proc, (void *)dargs.name);
			}
		}
		xdr_destroy(&xdrs);
		break;
		
	case NFSPROC_READ:
		memset(&rargs, 0, sizeof(rargs));
		xdrmem_create(&xdrs, buf, len, XDR_DECODE);
		
		if (xdr_readargs(&xdrs, &rargs)) {
			fname = fh_map_find(rargs.file.data, NFS_FHSIZE);
			if (fname != NULL) {
				ma = (struct myreadargs *) malloc(sizeof(*ma));
				if (ma != NULL) {
					ma->filename = fname;
					ma->offset = rargs.offset;
					xid_map_enter(xid, NFS_PROGRAM,
						      NFS_VERSION,
						      NFSPROC_READ,
						      (void *)ma);
				}
			}
		}
		xdr_destroy(&xdrs);
		break;
	}
}
开发者ID:IFGHou,项目名称:dsniff,代码行数:46,代码来源:filesnarf.c

示例8: printf

tImage* TextureManager::registerTexture(string path) 
{
	string trimmed_path, forced_ext;
	tImage *img;

	//std::count << path.length() << "test" << std::endl;
	printf("registeringShader:\n");

	if (path.length() <= 0) {
		return NULL;
	}

	trimmed_path = path.substr(0, path.find_last_of('.'));

	/* see if we've already loaded this shader */
	img = getTextureByName(trimmed_path);
	if (img != NULL) {
		std::cout << "\texisting texture found" << std::endl;
		return img;
	}

	/* check to see if this shader is just a static texture */
	if (regex_match(path.begin(), path.end(), image_file_regex)) {
		std::cout << "\tstatic texture detected: " << path << std::endl;
		img = _allocateTexture(path);

		// default path does not work, try .jpg instead
		if (img == NULL) {
			forced_ext = trimmed_path + DEFAULT_IMG_EXT;
			img = _allocateTexture(forced_ext);
		}
	} else {
		std::cout << "\tunsupported shader type " << path << std::endl;
	}

	if (img == NULL)
	{
		SHADOW_LOG_ERROR("UNABLE TO LOAD IMAGE");
		return NULL;
	}

	/* add this texture to the map */
	textures[trimmed_path] = img;

	return img;
}
开发者ID:tullrich,项目名称:cpp-shadows,代码行数:46,代码来源:TextureManager.cpp

示例9: re

wstring Parser::getFormMethod(wstring content)
{
	wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
	wstring method = L"";
	content.erase(remove(content.begin(), content.end(), '\t'), content.end());
	wstring contentInfo = content;

	const wregex re(L"(<form[^>]*method=['|\"](.*?)['|\"].*?>)", regex::icase);

	wsmatch results;
	if (regex_match(contentInfo.cbegin(), contentInfo.cend(), results, re))
	{
		method = results[1];
		wcout << "Method = " << method << endl;
	}
	return method;
}
开发者ID:DeukYeolChoe,项目名称:WebBrowser,代码行数:17,代码来源:parser.cpp

示例10: expression

   bool 
   RegularExpression::TestExactMatch(const String &sExpression, const String &sValue)
   {
      try
      {
         wregex expression(sExpression); 
         
         if(regex_match(sValue, expression)) 
            return true;
      }
      catch (std::runtime_error &) // regex_match will throw runtime_error if regexp is too complex.
      {
         return false;
      }

      return false;
   }
开发者ID:bogri5520,项目名称:hMailServer,代码行数:17,代码来源:RegularExpression.cpp

示例11: rgx

bool ParserList::getInstructionAndArguments(const string& userCommand,
        string& instruction,
        string& arguments) {
    regex rgx(regexInstructionAndArguments, regex_constants::icase);
    smatch matchResults;

    if (!regex_match(userCommand, matchResults, rgx)) {

        return false;
    }

    assert(matchResults.size() > ARGS_POS);
    instruction = matchResults[INSTRUCTION_POS];
    arguments = matchResults[ARGS_POS];

    return true;
}
开发者ID:sudarsangp,项目名称:todomanager,代码行数:17,代码来源:ParserList.cpp

示例12: hdr_plugin

static int
hdr_plugin(TSCont contp, TSEvent event, void *edata) 
{
	TSHttpTxn txnp = (TSHttpTxn)edata;

	switch (event) {
		case TS_EVENT_HTTP_READ_REQUEST_HDR:
			regex_match(contp, txnp);
			break;
		case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
			hdr_handler(contp, txnp);
			break;
		default:
			break;
	}
	return 0;
}
开发者ID:scw00,项目名称:traffic-server-test,代码行数:17,代码来源:add_header.c

示例13: parse

		bool RegexLineReader::parse (const std::string& line)
		{
			smatch match;

			this->row.clear ();

			if (!regex_match (line, match, this->regex))
				return false;

			for (auto& pair: this->lookup)
			{
				if (pair.first < match.size ())
					this->row.set (pair.second, Variant (match[pair.first]));
			}

			return true;
		}
开发者ID:r3c,项目名称:tesca,代码行数:17,代码来源:regex.cpp

示例14: s

void
file_chooser::on_file_type_changed ()
{
  Glib::RefPtr< Gtk::TreeSelection > s (file_type_.get_selection ());
  if (!s) return;

  Gtk::TreeModel::iterator it (s->get_selected ());
  if (!it) return;

  Gtk::TreeModel::Row r (*it);
  extension_list      l (r[column->exts]);

  if (l.empty ())
    {
      expander_.set_label (_("File Type"));
    }
  else
    {
      expander_.set_label ((format (_("File type: %1%"))
                            % r.get_value (column->text)).str ());

      if (!count (l.begin (), l.end (), get_current_extension ()))
        set_current_extension (l.front ());
    }

  if (!single_image_mode_)
    {
      single_file_.set_sensitive (supports_multi_image (get_current_name ()));
      if (!supports_multi_image (get_current_name ()))
        {
          if (!regex_match (get_current_name (), filename_re))
            {
              fs::path path (get_current_name ());
              fs::path stem (path.stem ());
              fs::path ext  (path.extension ());

              path = stem;
              path = path.native () + default_pattern_;
              path.replace_extension (ext);

              set_current_name (path.string ());
            }
        }
      single_file_.set_active (requests_single_file (get_current_name ()));
    }
}
开发者ID:sirjaren,项目名称:utsushi,代码行数:46,代码来源:file-chooser.cpp

示例15: socket

bool ReceptionClient::initialiserClient()
{
    int nombreEssai = 0;
    this->socketClient = socket(AF_INET, SOCK_STREAM, 0);
    if(this->socketClient < 0)
    {
        GestionnaireLogger::ecrirMessage(FATAL, "Impossible de créer la socket");
        return false;
    }
    struct sockaddr_in sin = { 0 }; /* initialise la structure avec des 0 */
    boost::regex expression ("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
    if(regex_match(this->ip, expression) == false)
    {
        //        resolution de nom
        struct hostent *hostinfo = NULL;
        hostinfo = gethostbyname(this->ip.c_str()); /* on récupère les informations de l'hôte auquel on veut se connecter */
        if (hostinfo == NULL) /* l'hôte n'existe pas */
        {
            GestionnaireLogger::ecrirMessage(ERROR, "Nom de domaine introuvable");
            close(this->socketClient);
            return false;
        }

        sin.sin_addr = *((struct in_addr *)hostinfo->h_addr); /* l'adresse se trouve dans le champ h_addr de la structure hostinfo */
    }
    else
    {
        sin.sin_addr.s_addr = inet_addr(this->ip.c_str());
    }

    sin.sin_port = htons(this->port); /* on utilise htons pour le port */
    sin.sin_family = AF_INET;

    while(connect(this->socketClient,(struct sockaddr *) &sin, sizeof(struct sockaddr)) == -1)
    {
        GestionnaireLogger::ecrirMessage(TypeMessage::ERROR, "Impossible de se connecter");
        nombreEssai++;
        if(nombreEssai == 10)
        {
            GestionnaireLogger::ecrirMessage(TypeMessage::FATAL, "Impossible de se connecter après dix essais");
            return false;
        }
        sleep(2);
    }
    return true;
}
开发者ID:azazel7,项目名称:Jinn,代码行数:46,代码来源:ReceptionClient.cpp


注:本文中的regex_match函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。