Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
illamint
Jun 26, 2005

According to The Oxford English Dictionary, the word "snapshot" was originally a hunting term.
I'm fairly new to C++ and I'm wondering what the regular expression library du jour is. For a project in my CS class, we have to parse fairly large files (right now I'm going line-by-line with the regular expression "^([A-Za-z0-9]+),([A-Za-z0-9]*),([A-Za-z0-9]*),(s?f?|f?s?);$"), and I'm using regex.h which is unfortunately incredibly slow. I see that there's Boost.Regex, but we have to hand in our source code at the end of the project and I'm not sure that it's feasible to merge the Boost shared library stuff into my makefiles just for this. Should I just parse it by hand? Is there a better solution? I'm used to being able to just go to the Java or Python docs and glance at the syntax in the manual but I'm having kindof a hard time doing that with C++.

Adbot
ADBOT LOVES YOU

illamint
Jun 26, 2005

According to The Oxford English Dictionary, the word "snapshot" was originally a hunting term.

Scaevolus posted:

Do all the lines in the file match this? If so, a regex is overkill.

vv also overkill. Writing a DFA for this would be very easy.
Match this? As in, always match? I mean, ideally they would, but we're supposed to catch syntax errors in input. It's funny, actually, this specific part of the project is an interpreter for a specific DFA language, so yeah, I thought about a DFA, but I've always just used regular expressions for things like this due to ease-of-use. I guess I'll just write up a DFA for it, since it doesn't really look like there's a library that I can assume exists on the instructor's computer.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply