LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Regular Expresions on C++ (https://www.linuxquestions.org/questions/programming-9/regular-expresions-on-c-194042/)

poeta_boy 06-16-2004 01:05 AM

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

maercin 06-16-2004 02:58 AM

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

Mohsen 06-16-2004 03:01 AM

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 ;).

Hko 06-16-2004 10:44 AM

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".

poeta_boy 06-17-2004 12:07 AM

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

maercin 06-17-2004 04:34 AM

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;
}


llama_meme 06-17-2004 06:07 AM

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

poeta_boy 06-18-2004 12:00 AM

thanks everyone! boost regex works like a charm!! strongly recommended

Thanks


All times are GMT -5. The time now is 10:58 AM.