Re: Regular Expressions



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?
> >>
> >>
> >
> >
>
>


.



Relevant Pages

  • Re: beginners Digest 13 Mar 2006 05:54:58 -0000 Issue 2791
    ... passed by the Parliament on 15th December 2005 and received Royal Assent ... Here is how I would go about writing the regex needed to pull the information ... Part 7 seems to be a four digit year. ... Next we need to identify the parts we want to capture. ...
    (perl.beginners)
  • Re: Regex - Ensure 0,1 occurrences from a list of possibilities
    ... It would be pretty easy to extend this or generate this for longer strings. ... Evwen though a simple piece of C# would be more elegant, I couldn't resist trying to see if it was possible with just Regex:) ... D-11 (repeated digit) ... Jesse Houwing ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Regex in java
    ... string data that is actually a BCD number. ... Seems to me regex can skip over white space. ... So I think it needs either one digit before the. ...
    (comp.lang.java.programmer)
  • Re: Regex - Ensure 0,1 occurrences from a list of possibilities
    ... matching strings with a 1 time use program. ... D-11 (repeated digit) ... A better wat woukd be to check the general format with a regex, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Regular Expression
    ... you did not say exactly how are your product codes. ... The regex did not properly work. ... >> Ludovic SOEUR. ... >>> I have a question to a regular expression. ...
    (microsoft.public.dotnet.languages.csharp)