Jump to content

RegEx in C++

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
So as most of you will probably know, my C++ knowledge is limited. I mainly use PHP. I am working on a C++ program for a class and figured it out except for some basic output, when I realized a regular expression would work great on it. Soon after I realized I had no clue how C++ handled Regular Expressions at all. I asked my teacher and he was not so sure what I was talking about so it might not be in any standard libraries. I am hoping that it is, and if so how would I use it?

Or would it be better to get an external library? Which seems a bit much for a small class project, I might try and find a different way of solving my output issue.

#2
ZekeDragon

ZekeDragon

    Writes binary right handed and hex left handed

  • Moderators
  • 2,103 posts
It's not supported in the C++ standard library, RegEx didn't become the "in" thing to add to languages by the time the standard popped up. Anyway, you can pick up RegEx with Boost, which as far as I've found for any serious project using C++ you need Boost.

You'll find a few things are left to be desired by the standard library, for the most part Boost fills that void.
Wow I changed my sig!

#3
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
sscanf can read formatted strings. Usually when I think I need a regular expression sscanf does the trick.