Re: Pattern Match
- From: "konrad Krupa" <konrad@xxxxxxxxxxxxxxx>
- Date: Thu, 13 Sep 2007 19:35:39 -0400
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,I don't think that would catch "123 45a".
On Sep 12, 1:14 pm, Doug Semler <dougsem...@xxxxxxxxx> wrote:That also works in PERL5 regex. It would've been even easier to use
On Sep 12, 11:21 am, Arnshea <arns...@xxxxxxxxx> wrote:doh! You're right - you need the trailing zero-width negative
On Sep 12, 8:19 am, "konrad Krupa" <kon...@xxxxxxxxxxxxxxx> wrote:Unfortunately that still matches the expression 3digit space 2digit
So,I believe the pattern you want is:
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:- Show quoted text -
On Sep 8, 10:24 pm, "konrad Krupa" <kon...@xxxxxxxxxxxxxxx>err, sorry the zero-width negative lookbehind assertion is
wrote:
Thanks for your replies.Ahh, ok. Try (?<!\d)\d{3}\s\d{2} as your pattern. Needed the
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>- Show quoted text -
wrote:
Thank you for the tip.Dude, define your problem. What, EXACTLY do you need to
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"P.S. If you want to get only the digit match, you'll want
<kon...@xxxxxxxxxxxxxxx> wrote:
I'm not expert in Pattern Matching and it would take me ahowbout something like
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.
[^\d]\d{3}\s+\d{2}
(Non digit followed by 3 digits followed by one or more
whitespace
followed by 2 digits)
to
capture
it by sticking it into a catpuring group, like this:
[^\d](\d{3}\s+\d{2
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 -
zero- width negative lookbehind assertion (basically a way of
saying "anything not to the left of a number").- Hide quoted
text -
- Show quoted text -
basically a way of saying anything not to the RIGHT of a
number.- Hide quoted text -
(?<!\d)\d{3}\s\d{2}
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 -
lookahead. Pretty cool imho - .Net regular expressions did what I
wouldn't have thought possible; improve on PERL5 regexps!
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 -
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
.
- References:
- Re: Pattern Match
- From: Arnshea
- Re: Pattern Match
- From: Jesse Houwing
- Re: Pattern Match
- Prev by Date: Re: Making a method public
- Next by Date: Re: Cross-thread operation not valid
- Previous by thread: Re: Pattern Match
- Next by thread: Re: Pattern Match
- Index(es):
Relevant Pages
|