I am using the Boost library under c++ to parse a load of text. I seem to be hav开发者_如何转开发ing a problem with this string
text text text Seat 6: player_name (11,111) text text text
I am trying to match on the middle bit, the seat number can be anything between 1 and 9, the player_name can be any character a-zA-Z and include numbers *_. and the value in the brackets can be 0 to 1,000,000 and should include ','
I have this regex which works in c# but won't work under boost, its not matching and I can't see why as in my RegexBuilder its coming back as correct:
Seat (?<seat_id>[0-9]): (?<player_name>[A-Z0-9]{1,}) (?<stack_size>\([0-9,]{1,}\))
Any ideas? I am going to leave out the <> because I am just going to match on the string and not worry about the individual values.
Thanks, R. Happy holloween.
You say the player name can include lowercase letters, but that's not what your code says. The code says player_name
can only be numbers and uppercase letters. Perhaps in your C# code you set a flag to omit case-sensitivity from the check. In Boost, that's regex_constants::icase
; use it when creating the regex
object.
Also, remember that regex_match
requires the expression to match the entire input string. If you want to know whether the regular expression matches anywhere in the input, then use regex_search
instead.
精彩评论