vim match errors out with regular expression (?:([^f])fe|([lr])f)$


Trying to build pluralize function with vim script

I have this regular expression copied from php script to make plural words

/(?:([^f])fe|([lr])f)$/i \1\2ves

However this does not work with vim

if "calf" =~ "\\v(?:([^f])fe|([lr])f)$" echo "matched" end if

it errors out E64: ? follows nothing

I think I don't fully understand this regular expression, and how can I make it use with vim script?


Vim's regular expression dialect is slightly different from the more common POSIX regexps and Perl-compatible regexps.

The ?: which is used for grouping without capturing the submatch is expressed in Vim as \%(...\) (or \v%(...) in <em>very magic</em> mode). Therefore, you have to use:

if 'calf' =~ '\v%([^f])fe|([lr])f)$'

(Note how I've switched to single quotes to avoid escaping the backslash.)


  • How to run panel regression with both individual and time fixed effects?
  • write jsonobject data to xml tags
  • Why does Visual Studio not link correctly as a matlab mex file against the rundll?
  • How do you pass a parameter back from an external assembler subroutine to a cobol program?
  • Using cross_val_predict against test data set
  • pg gem install on Mac OS Lion with rvm
  • InputDispatcher Error
  • Collect checkbox values in jQuery and POST them on submit
  • Laravel 5.3 blade decoding HTML Special Characters
  • Is there a way to rename directories recursively without using sed or rename?
  • Searching an XML file using PHP [closed]
  • Custom .ToString() Formats in .rdlc Reports
  • global:whereis_name() returns different Pid from different terminals
  • Why are my web pages zoomed in when I open them in Opera Mobile?
  • KornShell Printf - Padding a string
  • Sweave + RweaveHTML: cat output does not appear in the output
  • how to put include(phpfile) to variable?
  • PHP socket_read() only gets the first byte of the stream
  • Add class element based on the name of the page
  • Zend Framework 2, Module Redirect
  • PHP Handling Namespace with SimpleXML
  • Check all commands exit code within a bash script
  • How do I prepend to a stream in Bash?
  • manupulating a string to create directories in unix
  • Getting syntax error in mysql-php. You have an error in your SQL syntax;
  • removing last 3 characters on a file (file extension)
  • Installing PHP 7 on digitalocean
  • Get specific string
  • How does this usort cmp function actually work?
  • Stop Bash Script if Hive Fails
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Where to put my custom functions in Wordpress?
  • Display Images one by one with next and previous functionality
  • Upload files with Ajax and Jquery
  • R: gsub and capture
  • Numpy divide by zero. Why?
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • How to load view controller without button in storyboard?