List Info

Thread: Leave something out of a capturing group




Leave something out of a capturing group
country flaguser name
United States
2007-08-14 16:17:54
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-16 20:27:01
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
-~----------~----~----~----~------~----~------~--~---


[1-2]

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