Re: Pattern questions

2006-05-24 Thread Benji Fisher
On Tue, May 23, 2006 at 02:22:32PM +0200, Zdenek Sekera wrote:
  
   if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_+-[\]/\]')
 do something
   endif
  
   2. why when the pattern ends with '+' or '\+' do I get
  an error?

 Can you be more specific?  I tried

:let char = a
:echo char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_+-[\]/\]+'
:echo char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_+-[\]/\]\+'

and neither generated an error.

HTH --Benji Fisher


RE: Pattern questions

2006-05-24 Thread Zdenek Sekera
Hi, Benji

 On Tue, May 23, 2006 at 02:22:32PM +0200, Zdenek Sekera wrote:
   
if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_+-[\]/\]')
  do something
endif
   
2. why when the pattern ends with '+' or '\+' do I get
   an error?
 
  Can you be more specific?  I tried
 
 :let char = a
 :echo char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_+-[\]/\]+'
 :echo char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_+-[\]/\]\+'

Sorry, I should have been clearer:

Note the placement of the '+' in my pattern, somewhere
in the middle, there it doesn't cause any problem:

if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_+-[\]/\]'
 ^
 | here

The erroneous (in my judgement) patterns are (e.g.) are these:

if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_-[\]/\+]')
if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_-[\]/\\+]')

So the question is why is it OK to have '+' in the middle
and not at the end?

---Zdenek


Re: Pattern questions

2006-05-24 Thread Charles E Campbell Jr

Zdenek Sekera wrote:


Sorry, I should have been clearer:

Note the placement of the '+' in my pattern, somewhere
in the middle, there it doesn't cause any problem:

if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_+-[\]/\]'
^
| here

The erroneous (in my judgement) patterns are (e.g.) are these:

if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_-[\]/\+]')
if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_-[\]/\\+]')

So the question is why is it OK to have '+' in the middle
and not at the end?
 



It has nothing to do with +, and everything to do with - .  The - is a 
range character,
more commonly seen with something like [a-z] (which stands for all lower 
case characters).

You need to escape the minus sign (ie. \-).

Regards,
Chip Campbell



RE: Pattern questions

2006-05-24 Thread Zdenek Sekera
 -Original Message-
 From: Charles E Campbell Jr [mailto:[EMAIL PROTECTED] 
 Sent: 24 May 2006 15:55
 To: Zdenek Sekera
 Cc: vim-dev@vim.org
 Subject: Re: Pattern questions
 
 Zdenek Sekera wrote:
 
 Sorry, I should have been clearer:
 
 Note the placement of the '+' in my pattern, somewhere
 in the middle, there it doesn't cause any problem:
 
 if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_+-[\]/\]'
  ^
  | here
 
 The erroneous (in my judgement) patterns are (e.g.) are these:
 
 if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_-[\]/\+]')
 if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_-[\]/\\+]')
 
 So the question is why is it OK to have '+' in the middle
 and not at the end?
   
 
 
 It has nothing to do with +, and everything to do with - .  
 The - is a 
 range character,
 more commonly seen with something like [a-z] (which stands 
 for all lower 
 case characters).
 You need to escape the minus sign (ie. \-).

Ops, I missed that one. Obvious! Thanks.

---Zdenek


Re: Pattern questions

2006-05-23 Thread A.J.Mechelynck

Zdenek Sekera wrote:

I have this:

if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_+-[\]/\]')
  do something
endif

Basically it is checking for all non-alphanumeric chars
(expect '=').

1. how do I include the ' char?.
   I can't seem to find a proper way.
   (I'd like to keep the patter in enclosed in '...')

2. why when the pattern ends with '+' or '\+' do I get
   an error?

---Zdenek


1. Starting with version 7, you can have a single quote in a 
single-quoted string by doubling the single quote. Thus,  (four 
single quotes) represents one single quote and 'a''b' (quote a quote 
quote b quote) is a string consisting of the letters a and b with a 
single quote between them.


In all versions, you can concatenate strings, and a single quote can be 
enclosed in a double-quoted string. Thus, '' . ' (single double 
single space dot space double single double) is an expression whose 
value is a String consisting of a double quote followed by a single quote.


2. I don't know, but I think it's either a bug, or documented under 
:help pattern.txt somewhere.



Best regards,
Tony.


RE: Pattern questions

2006-05-23 Thread Zdenek Sekera
 -Original Message-
 From: A.J.Mechelynck [mailto:[EMAIL PROTECTED] 
 Sent: 23 May 2006 14:22
 To: Zdenek Sekera
 Cc: vim-dev@vim.org
 Subject: Re: Pattern questions
 
 Zdenek Sekera wrote:
  I have this:
 
  if (char =~ '\m[;|?:[EMAIL PROTECTED]*(){}\\_+-[\]/\]')
do something
  endif
 
  Basically it is checking for all non-alphanumeric chars
  (expect '=').
 
  1. how do I include the ' char?.
 I can't seem to find a proper way.
 (I'd like to keep the patter in enclosed in '...')
 
  2. why when the pattern ends with '+' or '\+' do I get
 an error?
 
  ---Zdenek
 
 
 1. Starting with version 7, you can have a single quote in a 
 single-quoted string by doubling the single quote. Thus,  (four 
 single quotes) represents one single quote and 'a''b' (quote a quote 
 quote b quote) is a string consisting of the letters a and b with a 
 single quote between them.
 

Arrrgh, missed that in the doc somewhere, I'm running vim7 
(I forgot to say so)

 In all versions, you can concatenate strings, and a single 
 quote can be 
 enclosed in a double-quoted string. Thus, '' . ' (single double 
 single space dot space double single double) is an expression whose 
 value is a String consisting of a double quote followed by a 
 single quote.
 

Arrrgh :-), that I new but didn't think of.

 2. I don't know, but I think it's either a bug, or documented under 
 :help pattern.txt somewhere.

My feelings, too, but I can't find it anywhere in the pattern.txt
(and I printer the newest on purpose :-)!

Thanks, Tony, for help.

---Zdenek