Re: Pattern Match



Hello again.


Thank you for the great discussion and all the postings.

I believe that the pattern Doug sent works.

Once again thanks for the effort.


"Jesse Houwing" <jesse.houwing@xxxxxxxxxxxxxxxx> wrote in message
news:21effc901a9938c9c47313469761@xxxxxxxxxxxxxxxxxxxxx
Hello Arnshea,

On Sep 12, 4:51 pm, Jesse Houwing <jesse.houw...@xxxxxxxxxxxxxxxx>
wrote:

Hello Arnshea,

On Sep 12, 1:14 pm, Doug Semler <dougsem...@xxxxxxxxx> wrote:

On Sep 12, 11:21 am, Arnshea <arns...@xxxxxxxxx> wrote:

On Sep 12, 8:19 am, "konrad Krupa" <kon...@xxxxxxxxxxxxxxx> wrote:

So,
Do you have any idea how to do it?
Konrad"Arnshea" <arns...@xxxxxxxxx> wrote in message
news:1189545404.830832.7160@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

On Sep 11, 5:05 pm,Arnshea<arns...@xxxxxxxxx> wrote:

On Sep 8, 10:24 pm, "konrad Krupa" <kon...@xxxxxxxxxxxxxxx>
wrote:

Thanks for your replies.

I have to find 3 digits followed by space and then 2 digits.
In front of the first digit there can be( doesn't have to) a
space but
not a
number.
After the last digit there can be(doesn't have to) a space but
not a
digit.
123 45
This sequence of numbers can be embedded in sentence or the
entire
sentence
can be just the sequence "123 45"
What is invalid is this:
12345 67890

I don't want 345 67 to be matched.

The numbers can be preceeded or followed by space for example:

" 123 45 "
" 123 45"
"123 45 "
This is valid.
I hope this helps.

Konrad."Doug Semler" <dougsem...@xxxxxxxxx> wrote in message

news:1189201587.321454.126580@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

On Sep 7, 12:58 pm, "konrad Krupa" <kon...@xxxxxxxxxxxxxxx>
wrote:

Thank you for the tip.

The pattern you suggested fixes problem 12345 6789

but I still need to get match on string that has only 123 45

Is there any way to get them in one pattern?

Konrad."Doug Semler" <dougsem...@xxxxxxxxx> wrote in message

news:1189179369.874384.278270@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
.

On Sep 7, 11:33 am, Doug Semler <dougsem...@xxxxxxxxx>
wrote:

On Sep 7, 11:16 am, "konrad Krupa"
<kon...@xxxxxxxxxxxxxxx> wrote:

I'm not expert in Pattern Matching and it would take me a
while
to
come
up
with the syntax for what I'm trying to do.
I hope there are some experts that can help me.
I'm trying to match /d/d/d/s/d/d in any text.
There could be spaces in front or after the pattern (the
nnn nn
could
be
without spaces also) but it shouldn't pick it up in case
like
this
1234 56768
above pattern would give me 234 56.

If I do this /s/d/d/d/s/d/d/s
then I have to have spaces in front and after it, which
is
not
the
case.
Konrad.
howbout something like
[^\d]\d{3}\s+\d{2}
(Non digit followed by 3 digits followed by one or more
whitespace
followed by 2 digits)
P.S. If you want to get only the digit match, you'll want
to
capture
it by sticking it into a catpuring group, like this:
[^\d](\d{3}\s+\d{2
Dude, define your problem. What, EXACTLY do you need to
match? What are you trying to find?

I gave you a pattern that matched 3 digits + one or more
spaces followed by two digits. Regardless of what came in
front or behind. You need to define your problem better. The
pattern I gave you will find 123 45.- Hide quoted text -

- Show quoted text -

Ahh, ok. Try (?<!\d)\d{3}\s\d{2} as your pattern. Needed the
zero- width negative lookbehind assertion (basically a way of
saying "anything not to the left of a number").- Hide quoted
text -

- Show quoted text -

err, sorry the zero-width negative lookbehind assertion is
basically a way of saying anything not to the RIGHT of a
number.- Hide quoted text -

- Show quoted text -

I believe the pattern you want is:

(?<!\d)\d{3}\s\d{2}

Unfortunately that still matches the expression 3digit space 2digit
pattern with digits following the pattern. Which he said he didn't
want. You need to match if prefix is absent as well, which would
be

(?<!\d)\d{3}\s\d{2}(?!\d)

which says: Match any 3 digits followed by a space followed by 2
digits that is not on either side of a digit.- Hide quoted text -

- Show quoted text -

doh! You're right - you need the trailing zero-width negative
lookahead. Pretty cool imho - .Net regular expressions did what I
wouldn't have thought possible; improve on PERL5 regexps!

That also works in PERL5 regex. It would've been even easier to use
the \b boundy:

\b\d{3}\s\d{2}\b would've had the same result. That even works in
much older PERL versions.

Jesse
--
Jesse Houwing
jesse.houwing at sogeti.nl- Hide quoted text -
- Show quoted text -

I don't think that would catch "123 45a".

You're completely correct. The original problem had shrunk (read slowly
deteriorated) in the message I replied to.

--
Jesse Houwing
jesse.houwing at sogeti.nl




.



Relevant Pages

  • Re: Pattern Match
    ... "Arnshea" wrote in message ... >> pattern with digits following the pattern. ... improve on PERL5 regexps! ...
    (microsoft.public.dotnet.languages.csharp)
  • modulo encrypt problem
    ... I am trying to get an extremely simple character string encryption function ... The pattern to be encrypted is a string of ASCII numeric digits. ...
    (comp.lang.c)
  • Re: Entropy in crystalization: up or down?
    ... Strings of digits without context are without ... have short and long blips, as in a Morse Code-type pattern, and these ... any string of digits in pi will be found within any ... artifact behind such patterns. ...
    (talk.origins)
  • Re: Trouble with $key to HASH when Numeric
    ... the end of a string -- in other words, this pattern will always match ... and capture either 5 digits or nothing; 2) the pattern is anchored to ... modifier, which you do not). ...
    (comp.lang.perl)
  • Re: Random?
    ... chosen number that follows a certain pattern (and there is ... The digits of pi are considered *randomish* in that they exhibit ... rest of you didn't have the lateral thinking skills. ... my keyboard. ...
    (sci.math)