
September 5th, 2011, 05:15 PM
|
|
Registered User
|
|
Join Date: Sep 2011
Posts: 1
Time spent in forums: 31 m 53 sec
Reputation Power: 0
|
|
|
Help Needed Matching a String, using Regex's Or function
Hi,
I just recently found out that Regex might be a way to solve a currently problem I am attempting to solve.
What I have is a string, like the following:
"Bill says............\"Oh, [player id=3425549]O'Sullivan[/player] cut that one up like a wee 9-iron!\" The ball sails straight between the sticks as [team id=44328]Reaper RFC[/team] ease out to a 7 point lead."
I want to be able to see if another string matches up to this one, but sort of working out every possible combination, I found out that Regex has a sort of or function, but I am having trouble getting it to work, in java...
Heres an example of the type of pattern I want to use on the above sentence:
"Bill says............\"Oh, ([player id=3425549]O'Sullivan[/player]|[player id=56746531]McDonnell[/player]|[player id=35604392]Lyons[/player]) cut that one up like a wee 9-iron!\" The ball sails straight between the sticks as ([team id=44328]Reapers[/team]|[team id=44328]Reaper RFC[/team]) ease out to a 7 point lead."
So when I compile the above pattern and run it against the previous sentence I am hoping to get a match, is this possible using Regex and Java, and if it is where am I going wrong with my pattern?
Thanks in advance
|