Question about regular expressions 
Author Message
 Question about regular expressions

Hello Scripters,

 I try to find a regular expression pattern, which excludes the "."
So, I want to have a match only, if there are no "." (point) characters
in the string. I saw a lot samples and have some (small) experience
with regex, but I am not able to exclude something (not only the point)!!!

 The pattern "[^.]" and "[^\.]" are not working, like I (!!) expect. But
this
is not restricted to the point, if I have a string "abcdef", I wish only to
get a match, if there is no "c" in it, independent from it's position.

What is wrong with my thinking??

Am looking for a solution and spent a lot of time to find more real
samples in the web, but found not much for VBScript! Or is there
a good book out in the market??

 May be, here is some help??

Best regards,
Manfred Braun

(Private)
Lange Roetterstrasse 7
D68167 Mannheim
Germany


(Remove the anti-spam-underscore to mail me!)



Wed, 24 Jul 2002 03:00:00 GMT  
 Question about regular expressions
Patterns can only search for things which *are* there. You can't match
against things which are not.

You can search for a set of characters which excludes some characters, such
as [^a-h] means look for something which isn't a-h. It doesn't mean succeed
if you can't find a-h.

What you need to do is search for the character you want to ensure *isn't*
in the string and use the success of the search to indicate failure, if you
see what I mean.

--
Dale Strickland-Clark
Out-Think Ltd, UK
Business Technology Experts


Quote:
> Hello Scripters,

>  I try to find a regular expression pattern, which excludes the "."
> So, I want to have a match only, if there are no "." (point) characters
> in the string. I saw a lot samples and have some (small) experience
> with regex, but I am not able to exclude something (not only the point)!!!

>  The pattern "[^.]" and "[^\.]" are not working, like I (!!) expect. But
> this
> is not restricted to the point, if I have a string "abcdef", I wish only
to
> get a match, if there is no "c" in it, independent from it's position.

> What is wrong with my thinking??

> Am looking for a solution and spent a lot of time to find more real
> samples in the web, but found not much for VBScript! Or is there
> a good book out in the market??

>  May be, here is some help??

> Best regards,
> Manfred Braun

> (Private)
> Lange Roetterstrasse 7
> D68167 Mannheim
> Germany


> (Remove the anti-spam-underscore to mail me!)



Wed, 24 Jul 2002 03:00:00 GMT  
 Question about regular expressions
I suggest diferent aproach.

if instr(MyString,".") = 0 Then
  ...  ' your code here
end if

Robert Knaus


Quote:
> Hello Scripters,

>  I try to find a regular expression pattern, which excludes the "."
> So, I want to have a match only, if there are no "." (point) characters
> in the string. I saw a lot samples and have some (small) experience
> with regex, but I am not able to exclude something (not only the point)!!!

>  The pattern "[^.]" and "[^\.]" are not working, like I (!!) expect. But
> this
> is not restricted to the point, if I have a string "abcdef", I wish only
to
> get a match, if there is no "c" in it, independent from it's position.

> What is wrong with my thinking??

> Am looking for a solution and spent a lot of time to find more real
> samples in the web, but found not much for VBScript! Or is there
> a good book out in the market??

>  May be, here is some help??

> Best regards,
> Manfred Braun

> (Private)
> Lange Roetterstrasse 7
> D68167 Mannheim
> Germany


> (Remove the anti-spam-underscore to mail me!)



Wed, 24 Jul 2002 03:00:00 GMT  
 Question about regular expressions
Hi Dale

 and thanks for your response. I tried this way too (there are some small
samples in the docs), but could'nt understand/realize that......From your
sample below, it becomes valid for each other character at any position, so,
if I would have a search string like "imho", the result would even become
true, so I found no solution so far.

Thanks and regards,
Manfred



Quote:
> Patterns can only search for things which *are* there. You can't match
> against things which are not.

> You can search for a set of characters which excludes some characters,
such
> as [^a-h] means look for something which isn't a-h. It doesn't mean
succeed
> if you can't find a-h.

> What you need to do is search for the character you want to ensure *isn't*
> in the string and use the success of the search to indicate failure, if
you
> see what I mean.

> --
> Dale Strickland-Clark
> Out-Think Ltd, UK
> Business Technology Experts



> > Hello Scripters,

> >  I try to find a regular expression pattern, which excludes the "."
> > So, I want to have a match only, if there are no "." (point) characters
> > in the string. I saw a lot samples and have some (small) experience
> > with regex, but I am not able to exclude something (not only the
point)!!!

> >  The pattern "[^.]" and "[^\.]" are not working, like I (!!) expect. But
> > this
> > is not restricted to the point, if I have a string "abcdef", I wish only
> to
> > get a match, if there is no "c" in it, independent from it's position.

> > What is wrong with my thinking??

> > Am looking for a solution and spent a lot of time to find more real
> > samples in the web, but found not much for VBScript! Or is there
> > a good book out in the market??

> >  May be, here is some help??

> > Best regards,
> > Manfred Braun

> > (Private)
> > Lange Roetterstrasse 7
> > D68167 Mannheim
> > Germany


> > (Remove the anti-spam-underscore to mail me!)



Thu, 25 Jul 2002 03:00:00 GMT  
 Question about regular expressions
Hello Robi,

 thanks so far, but I wished to go to a more generalized way with
expressions, "including" and "excluding", but found no solution so far.

Best regards,
Manfred



Quote:
> I suggest diferent aproach.

> if instr(MyString,".") = 0 Then
>   ...  ' your code here
> end if

> Robert Knaus



> > Hello Scripters,

> >  I try to find a regular expression pattern, which excludes the "."
> > So, I want to have a match only, if there are no "." (point) characters
> > in the string. I saw a lot samples and have some (small) experience
> > with regex, but I am not able to exclude something (not only the
point)!!!

> >  The pattern "[^.]" and "[^\.]" are not working, like I (!!) expect. But
> > this
> > is not restricted to the point, if I have a string "abcdef", I wish only
> to
> > get a match, if there is no "c" in it, independent from it's position.

> > What is wrong with my thinking??

> > Am looking for a solution and spent a lot of time to find more real
> > samples in the web, but found not much for VBScript! Or is there
> > a good book out in the market??

> >  May be, here is some help??

> > Best regards,
> > Manfred Braun

> > (Private)
> > Lange Roetterstrasse 7
> > D68167 Mannheim
> > Germany


> > (Remove the anti-spam-underscore to mail me!)



Thu, 25 Jul 2002 03:00:00 GMT  
 Question about regular expressions
howdy--

since . matches everything, you're not going to have any luck with [^.] unless you are matching an empty string.  But in general,

So to get a string only if it excludes the character 'c' :

good=(/c/g.test(stringGood)) ? "no good":stringGood;

T

Quote:

> Hello Scripters,

>  I try to find a regular expression pattern, which excludes the "."
> So, I want to have a match only, if there are no "." (point) characters
> in the string. I saw a lot samples and have some (small) experience
> with regex, but I am not able to exclude something (not only the point)!!!

>  The pattern "[^.]" and "[^\.]" are not working, like I (!!) expect. But
> this
> is not restricted to the point, if I have a string "abcdef", I wish only to
> get a match, if there is no "c" in it, independent from it's position.

> What is wrong with my thinking??

> Am looking for a solution and spent a lot of time to find more real
> samples in the web, but found not much for VBScript! Or is there
> a good book out in the market??

>  May be, here is some help??

> Best regards,
> Manfred Braun

> (Private)
> Lange Roetterstrasse 7
> D68167 Mannheim
> Germany


> (Remove the anti-spam-underscore to mail me!)



Sat, 27 Jul 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Help, really simple question w/ Regular Expressions

2. question about regular expression

3. Really Simple Question on Regular Expressions

4. A few questions about Regular Expressions

5. Regular Expression replace question

6. Regular Expression Question

7. Regular Expression Replace Question

8. Regular expression question

9. Regular Expression question

10. Regular Expressions Newbie Question

11. Regular expressions question

12. Regular Expression replace question

 

 
Powered by phpBB® Forum Software