Re: Regular Expressions
- From: "Ludovic SOEUR" <Ludovic_SOEUR@xxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 10:50:39 +0200
OK. That's more understandable.
The following regex
\b(?:[0-9][A-Z]|[A-Z])[A-Z0-9-&]*\b
does 1 2 and 3....I didn't understood 4.
With this
myText="This is a J2EE server.\nDo you know 4R&2PP protocol ?\nIn 2H-3H, it
would have taken 10H of hard work";
Regex.Match(myText,@"\b(?:[0-9][A-Z]|[A-Z])[A-Z0-9-&]*\b") will return
"J2EE", "4R&2PP", "2H-3H".
Hope it helps,
Ludovic SOEUR.
"Ken Kast" <ken@xxxxxxxxxxxxxxxxx> a écrit dans le message de
news:edm4pYdrFHA.3884@xxxxxxxxxxxxxxxxxxxxxxx
> OK, I understand your pattern.
>
> What I'm trying to do is identify acronyms in a document. I'm defining an
> acronym as:
> 1. It is a sequence of capital letters, digits, and certain punctuation,
to
> whit, -, &, /, (, ,).
> 2. It must begin with a letter or digit
> 3. If it begins with a digit, then there must be a letter.
> 4. Left and right parens must match up.
>
> I can do 1, 2 and 4. 3 is the one I'm struggling with.
>
> Ken
>
>
>
>
>
>
> "Ludovic SOEUR" <Ludovic_SOEUR@xxxxxxxxxxx> wrote in message
> news:uKON3xGrFHA.904@xxxxxxxxxxxxxxxxxxxxxxx
> > Could you explicit what you really want ?
> > This regex is maybe what you are looking for : all sequence of letter
and
> > digits that starts with a letter : "\b[a-zA-Z]\w*\b"
> > (or "\b[a-zA-Z]\w+\b" if you do not want sequences with only one char).
> > Then, use group fields to check the length of your sequences....
> >
> > Hope it helps,
> >
> > Ludovic SOEUR.
> >
> > "Ken Kast" <ken@xxxxxxxxxxxxxxxxx> a écrit dans le message de
> > news:esSJni$qFHA.2212@xxxxxxxxxxxxxxxxxxxxxxx
> >> I have 3 pattern sets (P1, P2, P3). I want to match the following
(sort
> >> of): (P1|P2)(P1|P2|P3)+ The sort of is that if a matchee begins with a
> > P2,
> >> then there has to be at least 1 P1 following it. Simple example (in
this
> >> case P3 is void): I want to find all (longest) sequences of letters and
> >> numbers, where the first character is a letter.
> >>
> >> Is this doable with regexp?
> >>
> >>
> >
> >
>
>
.
- References:
- Regular Expressions
- From: Ken Kast
- Re: Regular Expressions
- From: Ludovic SOEUR
- Re: Regular Expressions
- From: Ken Kast
- Regular Expressions
- Prev by Date: Re: Creation Generic class
- Next by Date: Re: new versus override
- Previous by thread: Re: Regular Expressions
- Next by thread: Re: Regular Expressions
- Index(es):
Relevant Pages
|