Re: Match First Sequence in Regular Expression?
- From: "Roger L. Cauvin" <roger@xxxxxxxxxxxx>
- Date: Thu, 26 Jan 2006 21:58:19 GMT
"Jordan Abel" <random832@xxxxxxxxx> wrote in message
news:slrndthvsh.2npi.random832@xxxxxxxxxxxxxxxx
> On 2006-01-26, Roger L. Cauvin <roger@xxxxxxxxxxxx> wrote:
>> Say I have some string that begins with an arbitrary sequence of
>> characters
>> and then alternates repeating the letters 'a' and 'b' any number of
>> times,
>> e.g.
>>
>> "xyz123aaabbaabbbbababbbbaaabb"
>>
>> I'm looking for a regular expression that matches the first, and only the
>> first, sequence of the letter 'a', and only if the length of the sequence
>> is
>> exactly 3.
>>
>> Does such a regular expression exist? If so, any ideas as to what it
>> could
>> be?
>
> I believe posix regex libraries always yield only the first match.
>
> by "exactly 3" do you mean "Four shalt thou not count, neither count
> thou two, excepting that thou then proceed to three. Five is right
> out.", or do you mean the first occurence of 3 a's no matter what
> follows it?
Someone on another newsgroup provided a solution:
..*?(?<![ab])aaab
--
Roger L. Cauvin
nospam_roger@xxxxxxxxxx (omit the "nospam_" part)
Cauvin, Inc.
Product Management / Market Research
http://www.cauvin-inc.com
.
- Follow-Ups:
- Re: Match First Sequence in Regular Expression?
- From: khan . saleemahmed
- Re: Match First Sequence in Regular Expression?
- References:
- Match First Sequence in Regular Expression?
- From: Roger L. Cauvin
- Re: Match First Sequence in Regular Expression?
- From: Jordan Abel
- Match First Sequence in Regular Expression?
- Prev by Date: Re: Copying files from UNIX to Windows
- Next by Date: Most powerful IRC client for Unix
- Previous by thread: Re: Match First Sequence in Regular Expression?
- Next by thread: Re: Match First Sequence in Regular Expression?
- Index(es):
Relevant Pages
|