|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
my challenges with merging 2 Regex.Matches<font color="red">Smith</font> or <font color="blue">Smith</font> inside strIn which contains a lot of HTML and lot of possible lines like above but sometimes those lines are green. I only want the matches that are red or blue. I can easily do this: Dim strMatch as string = "<font color=""red"">Smith</font>" Dim mc as System.Text.RegularExpressions.MatchCollection = _ System.Text.regularExpressions.Regex.Matches ( strIn, strMatch ) and that works for red. But how do I either merge a red match result with a blue match result, OR somehow use regex better so it knows to match either red or blue in a single pattern?
Show quote
Hide quote
"D. Patrick" <replywithinthegr***@thenotreal.com> wrote in message "<font color=""(red)|(blue)"">Smith</font>"news:R%dmg.3579$MF6.2782@tornado.socal.rr.com... > I'm trying to find all occurrences of either: > > <font color="red">Smith</font> > or > <font color="blue">Smith</font> > > inside strIn which contains a lot of HTML and lot of possible lines like > above but sometimes those lines are green. I only want the matches that > are red or blue. > > I can easily do this: > > Dim strMatch as string = "<font color=""red"">Smith</font>" > Dim mc as System.Text.RegularExpressions.MatchCollection = _ > System.Text.regularExpressions.Regex.Matches ( strIn, strMatch ) > > and that works for red. But how do I either merge a red match result with > a blue match result, OR somehow use regex better so it knows to match > either red or blue in a single pattern? > Try that, untested :) HTH, Mythran
Show quote
Hide quote
"Mythran" <kip_potter@hotmail.comREMOVETRAIL> wrote in message After testing my reply...I found that the following is probably what you news:OwqUG6VlGHA.4268@TK2MSFTNGP05.phx.gbl... > > "D. Patrick" <replywithinthegr***@thenotreal.com> wrote in message > news:R%dmg.3579$MF6.2782@tornado.socal.rr.com... >> I'm trying to find all occurrences of either: >> >> <font color="red">Smith</font> >> or >> <font color="blue">Smith</font> >> >> inside strIn which contains a lot of HTML and lot of possible lines like >> above but sometimes those lines are green. I only want the matches that >> are red or blue. >> >> I can easily do this: >> >> Dim strMatch as string = "<font color=""red"">Smith</font>" >> Dim mc as System.Text.RegularExpressions.MatchCollection = _ >> System.Text.regularExpressions.Regex.Matches ( strIn, strMatch ) >> >> and that works for red. But how do I either merge a red match result >> with a blue match result, OR somehow use regex better so it knows to >> match either red or blue in a single pattern? >> > > "<font color=""(red)|(blue)"">Smith</font>" > > Try that, untested :) > > HTH, > Mythran > want, instead: <font color=""(red|blue)"">Smith</font> HTH :) Mythran
Show quote
Hide quote
"Mythran" <kip_potter@hotmail.comREMOVETRAIL> wrote in message thank you. and what about if the font string is empty, such asnews:OD$ZiJXlGHA.3304@TK2MSFTNGP03.phx.gbl... > > "Mythran" <kip_potter@hotmail.comREMOVETRAIL> wrote in message > news:OwqUG6VlGHA.4268@TK2MSFTNGP05.phx.gbl... >> >> "D. Patrick" <replywithinthegr***@thenotreal.com> wrote in message >> news:R%dmg.3579$MF6.2782@tornado.socal.rr.com... >>> I'm trying to find all occurrences of either: >>> >>> <font color="red">Smith</font> >>> or >>> <font color="blue">Smith</font> >>> >>> inside strIn which contains a lot of HTML and lot of possible lines like >>> above but sometimes those lines are green. I only want the matches >>> that are red or blue. >>> >>> I can easily do this: >>> >>> Dim strMatch as string = "<font color=""red"">Smith</font>" >>> Dim mc as System.Text.RegularExpressions.MatchCollection = _ >>> System.Text.regularExpressions.Regex.Matches ( strIn, strMatch ) >>> >>> and that works for red. But how do I either merge a red match result >>> with a blue match result, OR somehow use regex better so it knows to >>> match either red or blue in a single pattern? >>> >> >> "<font color=""(red)|(blue)"">Smith</font>" >> >> Try that, untested :) >> >> HTH, >> Mythran >> > > After testing my reply...I found that the following is probably what you > want, instead: > > <font color=""(red|blue)"">Smith</font> > > HTH :) > > Mythran > color="" how would you package the empty into the choices? like this? ... <font color=""(red|blue|)"">Smith</font>
Show quote
Hide quote
"D. Patrick" <replywithinthegr***@thenotreal.com> wrote in message Possibly, test it and see :0news:PKkmg.3609$MF6.454@tornado.socal.rr.com... > > "Mythran" <kip_potter@hotmail.comREMOVETRAIL> wrote in message > news:OD$ZiJXlGHA.3304@TK2MSFTNGP03.phx.gbl... >> >> "Mythran" <kip_potter@hotmail.comREMOVETRAIL> wrote in message >> news:OwqUG6VlGHA.4268@TK2MSFTNGP05.phx.gbl... >>> >>> "D. Patrick" <replywithinthegr***@thenotreal.com> wrote in message >>> news:R%dmg.3579$MF6.2782@tornado.socal.rr.com... >>>> I'm trying to find all occurrences of either: >>>> >>>> <font color="red">Smith</font> >>>> or >>>> <font color="blue">Smith</font> >>>> >>>> inside strIn which contains a lot of HTML and lot of possible lines >>>> like above but sometimes those lines are green. I only want the >>>> matches that are red or blue. >>>> >>>> I can easily do this: >>>> >>>> Dim strMatch as string = "<font color=""red"">Smith</font>" >>>> Dim mc as System.Text.RegularExpressions.MatchCollection = _ >>>> System.Text.regularExpressions.Regex.Matches ( strIn, strMatch ) >>>> >>>> and that works for red. But how do I either merge a red match result >>>> with a blue match result, OR somehow use regex better so it knows to >>>> match either red or blue in a single pattern? >>>> >>> >>> "<font color=""(red)|(blue)"">Smith</font>" >>> >>> Try that, untested :) >>> >>> HTH, >>> Mythran >>> >> >> After testing my reply...I found that the following is probably what you >> want, instead: >> >> <font color=""(red|blue)"">Smith</font> >> >> HTH :) >> >> Mythran >> > > thank you. and what about if the font string is empty, such as > > color="" > > how would you package the empty into the choices? like this? ... > > <font color=""(red|blue|)"">Smith</font> > > Mythran |
|||||||||||||||||||||||