Insufficient quantifiers can be very useful. However, I can not come up with any use ??, reluctant version ?. Can someone give me an example, or is it just because other quantifiers also have reluctant versions?
??
?
Here is an example of a regular expression using a quantifier ??:
(?:\w+-??|-\w+)
It matches every word that either follows a hyphen or precedes a hyphen. In foo-barit will correspond to fooand -barnot foo-and barhow (?:\w+-?|-\w+).
foo-bar
foo
-bar
foo-
bar
(?:\w+-?|-\w+)
- , , ( #):
Match username = Regex.Match(input, @"^([\w\W]*?)(@[\w\W]+\.[\w\W])??$");
, , , , , @. , , , , @domain.com .
@
@domain.com
: , , - , . , ...;)
Perhaps, perhaps, if you want something in a different capture group than otherwise. I cannot remember having ever seen him, and I cannot come up with an example that would not be very far-fetched.
Source: https://habr.com/ru/post/1709370/More articles:Is DelegateCommand the same as "Attached Behavior"? - wpfHow to print a partially transparent image in a PDF canvas using Delphi? - printingFailed to load file or assembly System.EnterpriseServices - asp.netSpring AOP - how do I make a proxied bean? - springWhat is the advantage of other testing libraries over versions of Visual Studio 2008? - unit-testingIs there a way to detect a Unicode alphanumeric character? - c ++Does MSDeploy support updating websites and databases? - iisundefined parameters and session hashes in before_filter - debuggingQuerying multiple databases on SQL Server - .netDrupal / Ubercart ... node style? - stylingAll Articles