LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-16-2004, 01:05 AM   #1
poeta_boy
Member
 
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Rep: Reputation: 31
Regular Expresions on C++


Hi!

is there such a thing as regular expresions and their evaluations in C++?

like finding substrings and all

Thanks a lot!!

poeta
 
Old 06-16-2004, 02:58 AM   #2
maercin
LQ Newbie
 
Registered: Mar 2004
Posts: 7

Rep: Reputation: 0
Regular expressions are not part of C++ standard. You have to use a library to do any regular expressions magic. Here is one worth taking a look at:

Boost regex library
 
Old 06-16-2004, 03:01 AM   #3
Mohsen
Member
 
Registered: Feb 2003
Location: Iran
Distribution: Solaris 10
Posts: 201

Rep: Reputation: 30
There is nothing builtin C/C++ functions or libraries for matching regex offered by ANSI, but you may find lots of libraries on the Internet. Just make a google seasrch .
 
Old 06-16-2004, 10:44 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
There is nothing builtin C/C++ functions or libraries for matching regex offered by ANSI
Not by ANSI I assume. But in the GNU C libs and POSIX there is. So on Linux it's readily available.

See "man regcomp".

Last edited by Hko; 06-16-2004 at 10:47 AM.
 
Old 06-17-2004, 12:07 AM   #5
poeta_boy
Member
 
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Original Poster
Rep: Reputation: 31
thanks a lot !!! I've downloaded Boost Regex and it seems to be working ok........ just a question........... I'm very shy about asking it.... what does it mean when a method has parameters separated by | pipe?

void method (param | param)

a really newbie question but I haven't used it before!!! now that I using this regex (I was reading the files it has) and some openGL I noticed this... please help!

Thanks
 
Old 06-17-2004, 04:34 AM   #6
maercin
LQ Newbie
 
Registered: Mar 2004
Posts: 7

Rep: Reputation: 0
In c++ the '|' character stands for bitwise inclusive or operator. Its operands can be integral or enumeration types (the usual arithmetic conversions are applied). For example 3 | 5 = 7

To get the result convert the operands to binary form and OR each bit individually:

011
101
----
111

Here is C++ code to demonstrate this:

Code:
#include<iostream>

int main() {
    std::cout << (3|5) << std::endl;

    return 0;
}
 
Old 06-17-2004, 06:07 AM   #7
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
In more practical terms, the | operator is often used to combine boolean options. So foo(X | Y | Z) means call foo with the option X, Y and Z all set. This still works in terms of bitwise OR &mdash; the various options are constant integers with all the bits except for a single 1 set to 0.

Alex
 
Old 06-18-2004, 12:00 AM   #8
poeta_boy
Member
 
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Original Poster
Rep: Reputation: 31
thanks everyone! boost regex works like a charm!! strongly recommended

Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
regular expresions: java: matching lines with out string zymos Programming 1 05-28-2005 09:17 AM
Regular Expressions overbored Linux - Software 3 06-24-2004 02:34 PM
Regular expressions aromes Linux - General 1 10-15-2003 12:29 PM
Regular Expression Help WeNdeL Linux - General 1 08-14-2003 10:08 AM
regular expression gumby Programming 3 07-15-2003 12:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration