3 Replies - 2954 Views - Last Post: 02 December 2011 - 05:22 AM Rate Topic: -----

#1 time4f5  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 57
  • Joined: 02-December 11

regular expression example C++

Posted 02 December 2011 - 04:52 AM

Hello all, I'm taking a class an one of the sections that we are discussing is regular expressions. The class isn't language specific, meaning I haven't seen any examples. I'm trying to see the value of regular expressions and also see an example in C++.
Can someone provide an example? It doesn't matter what it is. it could be a phone number, date, etc.

once assignment we had in class was to find a string [a -z] the word "computer" and another string [a - z]
the answer is [a - z]*(computer)[a - z]*
but I'm not sure what that looks like in C++, any help would be appreciated. thanks
*Not a homework assignment

Is This A Good Question/Topic? 0
  • +

Replies To: regular expression example C++

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6036
  • View blog
  • Posts: 23,418
  • Joined: 23-August 08

Re: regular expression example C++

Posted 02 December 2011 - 05:12 AM

In C, not C++

C++ through the Boost library
Was This Post Helpful? 2
  • +
  • -

#3 Anarion  Icon User is offline

  • The Persian Coder
  • member icon

Reputation: 282
  • View blog
  • Posts: 1,456
  • Joined: 16-May 09

Re: regular expression example C++

Posted 02 December 2011 - 05:19 AM

Regular expression wasn't part of the C++ in the previous standard. In the new C++11 standard, this feature is added. Have a look Here for an example.
Though, this is a new standard and it takes time for compilers to fully support the new features. So, using this feature depends on the compiler you are using and whether it has support yet or not.

Also, you can use other libraries which provide this functionality. For example, boost::regex.
Was This Post Helpful? 2
  • +
  • -

#4 time4f5  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 57
  • Joined: 02-December 11

Re: regular expression example C++

Posted 02 December 2011 - 05:22 AM

nice resources, thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1