How do (*SKIP) or (*F) work on regex?

前端 未结 2 1859
有刺的猬
有刺的猬 2020-11-21 06:54

I\'m learning an advanced usage of regex and noticed that many posts use (*SKIP) or (*F) in it.

I posted a question where the idea was to m

2条回答
  •  -上瘾入骨i
    2020-11-21 07:20

    The (*SKIP) and (*F) (aka *FAIL) patterns are documented in the Perl manual: http://perldoc.perl.org/perlre.html

    However, they are only available in Perl and in flavours of regex that imitate Perl (for example the PCRE library used by PHP).

    Java's built in regex engine does not support these extensions, and I am not aware of one that does.

    My general advice in Java is to keep your regular expressions simple, and use other string manipulation methods to achieve what can't be done clearly with a short regex.

提交回复
热议问题