views:

16

answers:

1

Hi,

I have imported Boost library in to a .dll that I am using. I am trying to parse a string using:

boost::wregex regPlayerAtSeat(L"*Governor: Seat.?[1-9].*");

But all I get is an 'interop service exception. Is the syntax of my regex wrong?

Thanks, R.

+1  A: 

The first * doesn't appear to have any characters before it. In regex it acts as a quantifier, not a wildcard like in UNIX command lines and so forth. You probably want something like .* in its place, but that's partly just a guess. The full regex would then look like this:

boost::wregex regPlayerAtSeat(L".*Governor: Seat.?[1-9].*");

.* will match zero or more repetitions of (almost) any character (probably not newlines, but I don't know the inner workings of the boost regex engine). Is that what you were going for at the beginning of your string? Alternatively, since you haven't anchored your regex, you might be able to just use:

boost::wregex regPlayerAtSeat(L"Governor: Seat.?[1-9]");

This will depend on what exactly you're trying to match and what format it is in, however.

eldarerathis
Thank you, you were right with the .*, don't know why I didn't spot it. I was having problems installing the boost libraries and because of the way it showed in the debugger I was wondering if a .dll was mising... long story. Anyway, thanks.
flavour404