> I'm trying to get a matchstr function to return me the string of
> printable character, excluding the white space.  So for example,
>         :echo matchstr(":foo^[bar", ':\p*')
> return "foo" since ^[ is the esc character.
> 
> And
>         :echo matchstr(":foo bar", ':\S*')
> returns "foo" as well.
> 
> I'm using the colon in this example for the first part in matching the
> string, but how do I combine the two printable character and exclude
> white space regexes into the same expression so that it can handle
> both strings ":foo bar^[bar" and ":foo^]bar bar" and extract "foo"?

I'm not sure what you want...you say you want the printables, 
without spaces, but then you say you only want "foo" which 
excludes bar (printable chars) and the colon.  You might try one of

   echo substitute(':foo^[bar', '[^[:graph:]]\+', '', 'g')
   echo substitute(':foo^[bar', '[^[:print:]]\+', '', 'g')
   echo matchstr(':foo^[bar', '[[:graph:]]\+')

or some permutation thereof.  You may want to read up at

   :help substitute()
   :h [:graph:]
   :h [:print:]

If you give a clearer list of inputs and desired outputs, it 
might be possible to give a more precise answer.

-tim








--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to