List Info

Thread: RE: Leave something out of a capturing group




RE: Leave something out of a capturing group
country flaguser name
United States
2007-08-17 07:53:54
Thanks. Unfortunately, I don't have the luxury of
concatenating the two
capture groups. I need the value returned in a single
capture group.

-----Original Message-----
From: regexgooglegroups.com [mailto:regexgooglegroups.com]On Behalf
Of
Sergei Z
Sent: Thursday, August 16, 2007 9:27 PM
To: Regex
Subject: Re: Leave something out of a capturing group



if u use

(?:(He)ll(o))

then group #1 will return *He*
and group #2 will return *o*

and u cannot really split the whole match *hello* [i.e.
group #0] ,
it'll be there anyway.


On Aug 14, 5:17 pm, brian <bdun...dunbarconsulting.org>
wrote:
> I am trying to match a string and leave part of the
match out of the
> matching group. For example:
>
> Source String:
>
> Hi Hello Hi
>
> Regex that almost does what I want:
>
> .*(He(?:ll)o).*
>
> $1 returns "Hello" and what I want is
"Heo", with the two l's removed
> corresponding to the non-capturing group.
>
> Is what I want doable?
>
> Thanks




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: Leave something out of a capturing group
country flaguser name
United States
2007-08-17 09:53:54
it is logically impossible b/c u want to return a piece of
text that
originally wasn't present in the text u r processing. This
operation
requires additional modification/string processing that
recuires more
code aside from pure regex.

On Aug 17, 8:53 am, "Brian E. Dunbar"
<bdun...dunbarconsulting.org>
wrote:
> Thanks. Unfortunately, I don't have the luxury of
concatenating the two
> capture groups. I need the value returned in a single
capture group.
>
>
>
> -----Original Message-----
> From: regexgooglegroups.com [mailto:regexgooglegroups.com]On Behalf Of
>
> Sergei Z
> Sent: Thursday, August 16, 2007 9:27 PM
> To: Regex
> Subject: Re: Leave something out of a capturing group
>
> if u use
>
> (?:(He)ll(o))
>
> then group #1 will return *He*
> and group #2 will return *o*
>
> and u cannot really split the whole match *hello* [i.e.
group #0] ,
> it'll be there anyway.
>
> On Aug 14, 5:17 pm, brian <bdun...dunbarconsulting.org> wrote:
> > I am trying to match a string and leave part of
the match out of the
> > matching group. For example:
>
> > Source String:
>
> > Hi Hello Hi
>
> > Regex that almost does what I want:
>
> > .*(He(?:ll)o).*
>
> > $1 returns "Hello" and what I want is
"Heo", with the two l's removed
> > corresponding to the non-capturing group.
>
> > Is what I want doable?
>
> > Thanks- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )