CINXE.COM
Regex Tutorial - Possessive Quantifiers
<!DOCTYPE html> <html lang="en"><head><meta charset="utf-8"><link rel=canonical href='https://https://www.regular-expressions.info//possessive.html'><title>Regex Tutorial - Possessive Quantifiers</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="author" content="Jan Goyvaerts"> <meta name="description" content="Speed up your regular expressions with possessive quantifiers"> <meta name="keywords" content=""> <link rel=stylesheet href="regex.css" type="text/css"><script src="theme.js" type="text/javascript"></script><link rel="alternate" type="application/rss+xml" title="New at Regular-Expressions.info" href="updates.xml"> </head> <body bgcolor=white text=black> <div id=top></div> <div id=btntop><div id=btngrid><a href="quickstart.html" target="_top"><div>Quick Start</div></a><a href="tutorial.html" target="_top"><div>Tutorial</div></a><a href="tools.html" target="_top"><div>Tools & Languages</div></a><a href="examples.html" target="_top"><div>Examples</div></a><a href="refflavors.html" target="_top"><div>Reference</div></a><a href="books.html" target="_top"><div>Book Reviews</div></a></div></div> <div id=contents><div id=side> <TABLE CLASS=side CELLSPACING=0 CELLPADDING=4><TR><TD CLASS=sideheader>Regex Tutorial</TD></TR><TR><TD><A HREF="tutorial.html" TARGET=_top>Introduction</A></TD></TR><TR><TD><A HREF="tutorialcnt.html" TARGET=_top>Table of Contents</A></TD></TR><TR><TD><A HREF="characters.html" TARGET=_top>Special Characters</A></TD></TR><TR><TD><A HREF="nonprint.html" TARGET=_top>Non-Printable Characters</A></TD></TR><TR><TD><A HREF="engine.html" TARGET=_top>Regex Engine Internals</A></TD></TR><TR><TD><A HREF="charclass.html" TARGET=_top>Character Classes</A></TD></TR><TR><TD><A HREF="charclasssubtract.html" TARGET=_top>Character Class Subtraction</A></TD></TR><TR><TD><A HREF="charclassintersect.html" TARGET=_top>Character Class Intersection</A></TD></TR><TR><TD><A HREF="shorthand.html" TARGET=_top>Shorthand Character Classes</A></TD></TR><TR><TD><A HREF="dot.html" TARGET=_top>Dot</A></TD></TR><TR><TD><A HREF="anchors.html" TARGET=_top>Anchors</A></TD></TR><TR><TD><A HREF="wordboundaries.html" TARGET=_top>Word Boundaries</A></TD></TR><TR><TD><A HREF="alternation.html" TARGET=_top>Alternation</A></TD></TR><TR><TD><A HREF="optional.html" TARGET=_top>Optional Items</A></TD></TR><TR><TD><A HREF="repeat.html" TARGET=_top>Repetition</A></TD></TR><TR><TD><A HREF="brackets.html" TARGET=_top>Grouping & Capturing</A></TD></TR><TR><TD><A HREF="backref.html" TARGET=_top>Backreferences</A></TD></TR><TR><TD><A HREF="backref2.html" TARGET=_top>Backreferences, part 2</A></TD></TR><TR><TD><A HREF="named.html" TARGET=_top>Named Groups</A></TD></TR><TR><TD><A HREF="backrefrel.html" TARGET=_top>Relative Backreferences</A></TD></TR><TR><TD><A HREF="branchreset.html" TARGET=_top>Branch Reset Groups</A></TD></TR><TR><TD><A HREF="freespacing.html" TARGET=_top>Free-Spacing & Comments</A></TD></TR><TR><TD><A HREF="unicode.html" TARGET=_top>Unicode</A></TD></TR><TR><TD><A HREF="modifiers.html" TARGET=_top>Mode Modifiers</A></TD></TR><TR><TD><A HREF="atomic.html" TARGET=_top>Atomic Grouping</A></TD></TR><TR><TD><A HREF="possessive.html" TARGET=_top>Possessive Quantifiers</A></TD></TR><TR><TD><A HREF="lookaround.html" TARGET=_top>Lookahead & Lookbehind</A></TD></TR><TR><TD><A HREF="lookaround2.html" TARGET=_top>Lookaround, part 2</A></TD></TR><TR><TD><A HREF="keep.html" TARGET=_top>Keep Text out of The Match</A></TD></TR><TR><TD><A HREF="conditional.html" TARGET=_top>Conditionals</A></TD></TR><TR><TD><A HREF="balancing.html" TARGET=_top>Balancing Groups</A></TD></TR><TR><TD><A HREF="recurse.html" TARGET=_top>Recursion</A></TD></TR><TR><TD><A HREF="subroutine.html" TARGET=_top>Subroutines</A></TD></TR><TR><TD><A HREF="recurseinfinite.html" TARGET=_top>Infinite Recursion</A></TD></TR><TR><TD><A HREF="recurserepeat.html" TARGET=_top>Recursion & Quantifiers</A></TD></TR><TR><TD><A HREF="recursecapture.html" TARGET=_top>Recursion & Capturing</A></TD></TR><TR><TD><A HREF="recursebackref.html" TARGET=_top>Recursion & Backreferences</A></TD></TR><TR><TD><A HREF="recursebacktrack.html" TARGET=_top>Recursion & Backtracking</A></TD></TR><TR><TD><A HREF="posixbrackets.html" TARGET=_top>POSIX Bracket Expressions</A></TD></TR><TR><TD><A HREF="zerolength.html" TARGET=_top>Zero-Length Matches</A></TD></TR><TR><TD><A HREF="continue.html" TARGET=_top>Continuing Matches</A></TD></TR> </TABLE><TABLE CLASS=side CELLSPACING=0 CELLPADDING=4><TR><TD CLASS=sideheader>More on This Site</TD></TR><TR><TD><A HREF="index.html" TARGET=_top>Introduction</A></TD></TR><TR><TD><A HREF="quickstart.html" TARGET=_top>Regular Expressions Quick Start</A></TD></TR><TR><TD><A HREF="tutorial.html" TARGET=_top>Regular Expressions Tutorial</A></TD></TR><TR><TD><A HREF="replacetutorial.html" TARGET=_top>Replacement Strings Tutorial</A></TD></TR><TR><TD><A HREF="tools.html" TARGET=_top>Applications and Languages</A></TD></TR><TR><TD><A HREF="examples.html" TARGET=_top>Regular Expressions Examples</A></TD></TR><TR><TD><A HREF="refflavors.html" TARGET=_top>Regular Expressions Reference</A></TD></TR><TR><TD><A HREF="refreplace.html" TARGET=_top>Replacement Strings Reference</A></TD></TR><TR><TD><A HREF="books.html" TARGET=_top>Book Reviews</A></TD></TR><TR><TD><A HREF="print.html" TARGET=_top>Printable PDF</A></TD></TR><TR><TD><A HREF="about.html" TARGET=_top>About This Site</A></TD></TR><TR><TD><A HREF="updates.html" TARGET=_top>RSS Feed & Blog</A></TD></TR></TABLE></DIV><div class=bodytext><div class=topad style="height:130px"><A HREF="https://www.regexbuddy.com/create.html" TARGET="_top"><picture><source media="(max-width: 370px)" srcset="ads/320/rxbtutorial100.png 1x, ads/320/rxbtutorial150.png 1.5x, ads/320/rxbtutorial200.png 2x, ads/320/rxbtutorial250.png 2.5x, ads/320/rxbtutorial300.png 3x, ads/320/rxbtutorial350.png 3.5x, ads/320/rxbtutorial400.png 4x"><source media="(max-width: 500px)" srcset="ads/360/rxbtutorial100.png 1x, ads/360/rxbtutorial150.png 1.5x, ads/360/rxbtutorial200.png 2x, ads/360/rxbtutorial250.png 2.5x, ads/360/rxbtutorial300.png 3x, ads/360/rxbtutorial350.png 3.5x, ads/360/rxbtutorial400.png 4x"><source media="(max-width: 660px)" srcset="ads/480/rxbtutorial100.png 1x, ads/480/rxbtutorial150.png 1.5x, ads/480/rxbtutorial200.png 2x, ads/480/rxbtutorial250.png 2.5x, ads/480/rxbtutorial300.png 3x, ads/480/rxbtutorial350.png 3.5x, ads/480/rxbtutorial400.png 4x"><source media="(max-width: 747px)" srcset="ads/640/rxbtutorial100.png 1x, ads/640/rxbtutorial150.png 1.5x, ads/640/rxbtutorial200.png 2x, ads/640/rxbtutorial250.png 2.5x, ads/640/rxbtutorial300.png 3x, ads/640/rxbtutorial350.png 3.5x, ads/640/rxbtutorial400.png 4x"><img src="ads/728/rxbtutorial100.png" srcset="ads/728/rxbtutorial100.png 1x, ads/728/rxbtutorial125.png 1.25x, ads/728/rxbtutorial150.png 1.5x, ads/728/rxbtutorial175.png 1.75x, ads/728/rxbtutorial200.png 2x, ads/728/rxbtutorial250.png 2.5x, ads/728/rxbtutorial300.png 3x, ads/728/rxbtutorial350.png 3.5x, ads/728/rxbtutorial400.png 4x" alt="RegexBuddy鈥擝etter than a regular expression tutorial!"></picture></A></div> <div class=bulb><h1>Possessive Quantifiers</h1><script type="text/javascript">showbulb();</script></div> <p>The topic on <A HREF="repeat.html" TARGET="_top">repetition operators or quantifiers</A> explains the difference between greedy and lazy repetition. Greediness and laziness determine the order in which the regex engine tries the possible permutations of the regex pattern. A greedy quantifier first tries to repeat the token as many times as possible, and gradually gives up matches as the engine backtracks to find an overall match. A lazy quantifier first repeats the token as few times as required, and gradually expands the match as the engine backtracks through the regex to find an overall match.</p> <p>Because greediness and laziness change the order in which permutations are tried, they can change the overall regex match. However, they do not change the fact that the regex engine will backtrack to try all possible permutations of the regular expression in case no match can be found.</p> <p>Possessive quantifiers are a way to prevent the regex engine from trying all permutations. This is primarily useful for performance reasons. You can also use possessive quantifiers to eliminate certain matches.</p> <p>Of the regex flavors discussed in this tutorial, possessive quantifiers are supported by <A HREF="jgsoft.html" TARGET="_top">JGsoft</A>, <A HREF="java.html" TARGET="_top">Java</A>, and <A HREF="pcre.html" TARGET="_top">PCRE</A>. That includes languages with regex support based on PCRE such as <A HREF="php.html" TARGET="_top">PHP</A>, <A HREF="delphi.html" TARGET="_top">Delphi</A>, and <A HREF="rlanguage.html" TARGET="_top">R</A>. <A HREF="python.html" TARGET="_top">Python</A> supports possessive quantifiers starting with Python 3.11, <A HREF="perl.html" TARGET="_top">Perl</A> supports them starting with Perl 5.10, <A HREF="ruby.html" TARGET="_top">Ruby</A> starting with Ruby 1.9, and <A HREF="boost.html" TARGET="_top">Boost</A> starting with Boost 1.42.</p> <h2>How Possessive Quantifiers Work</h2> <p>Like a greedy quantifier, a possessive quantifier repeats the token as many times as possible. Unlike a greedy quantifier, it does <i>not</i> give up matches as the engine backtracks. With a possessive quantifier, the deal is all or nothing. You can make a quantifier possessive by placing an extra <tt>+</tt> after it. <tt>*</tt> is greedy, <tt>*?</tt> is lazy, and <tt>*+</tt> is possessive. <tt>++</tt>, <tt>?+</tt> and <tt>{n,m}+</tt> are all possessive as well.</p> <p>Let鈥檚 see what happens if we try to match <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN><SPAN CLASS="regexccopen">[</SPAN><SPAN CLASS="regexccspecial">^</SPAN><SPAN CLASS="regexccliteral">"</SPAN><SPAN CLASS="regexccopen">]</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexspecial">+</SPAN><SPAN CLASS="regexplain">"</SPAN></TT> against <tt class=string>"abc"</tt>. The <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> matches the <tt class=match>"</tt>. <TT CLASS=syntax><SPAN CLASS="regexccopen">[</SPAN><SPAN CLASS="regexccspecial">^</SPAN><SPAN CLASS="regexccliteral">"</SPAN><SPAN CLASS="regexccopen">]</SPAN></TT> matches <tt class=match>a</tt>, <tt class=match>b</tt> and <tt class=match>c</tt> as it is repeated by the <A HREF="repeat.html" TARGET="_top">star</A>. The final <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> then matches the final <tt class=match>"</tt> and we found an overall match. In this case, the end result is the same, whether we use a greedy or possessive quantifier. There is a slight performance increase though, because the possessive quantifier doesn鈥檛 have to remember any backtracking positions.</p> <p>The performance increase can be significant in situations where the regex fails. If the subject is <tt class=string>"abc</tt> (no closing quote), the above matching process happens in the same way, except that the second <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> fails. When using a possessive quantifier, there are no steps to backtrack to. The regular expression does not have any alternation or non-possessive quantifiers that can give up part of their match to try a different permutation of the regular expression. So the match attempt fails immediately when the second <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> fails.</p> <p>Had we used <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN><SPAN CLASS="regexccopen">[</SPAN><SPAN CLASS="regexccspecial">^</SPAN><SPAN CLASS="regexccliteral">"</SPAN><SPAN CLASS="regexccopen">]</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexplain">"</SPAN></TT> with a greedy quantifier instead, the engine would have backtracked. After the <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> failed at the end of the string, the <TT CLASS=syntax><SPAN CLASS="regexccopen">[</SPAN><SPAN CLASS="regexccspecial">^</SPAN><SPAN CLASS="regexccliteral">"</SPAN><SPAN CLASS="regexccopen">]</SPAN><SPAN CLASS="regexspecial">*</SPAN></TT> would give up one match, leaving it with <tt class=match>ab</tt>. The <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> would then fail to match <tt class=string>c</tt>. <TT CLASS=syntax><SPAN CLASS="regexccopen">[</SPAN><SPAN CLASS="regexccspecial">^</SPAN><SPAN CLASS="regexccliteral">"</SPAN><SPAN CLASS="regexccopen">]</SPAN><SPAN CLASS="regexspecial">*</SPAN></TT> backtracks to just <tt class=match>a</tt>, and <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> fails to match <tt class=string>b</tt>. Finally, <TT CLASS=syntax><SPAN CLASS="regexccopen">[</SPAN><SPAN CLASS="regexccspecial">^</SPAN><SPAN CLASS="regexccliteral">"</SPAN><SPAN CLASS="regexccopen">]</SPAN><SPAN CLASS="regexspecial">*</SPAN></TT> backtracks to match zero characters, and <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> fails <tt class=string>a</tt>. Only at this point have all backtracking positions been exhausted, and does the engine give up the match attempt. Essentially, this regex performs as many needless steps as there are characters following the unmatched opening quote.</p> <h2>When Possessive Quantifiers Matter</h2> <p>The main practical benefit of possessive quantifiers is to speed up your regular expression. In particular, possessive quantifiers allow your regex to fail faster. In the above example, when the closing quote fails to match, we <i>know</i> the regular expression couldn鈥檛 possibly have skipped over a quote. So there鈥檚 no need to backtrack and check for the quote. We make the regex engine aware of this by making the quantifier possessive. In fact, some engines, including the <A HREF="jgsoft.html" TARGET="_top">JGsoft</A> engine, detect that <TT CLASS=syntax><SPAN CLASS="regexccopen">[</SPAN><SPAN CLASS="regexccspecial">^</SPAN><SPAN CLASS="regexccliteral">"</SPAN><SPAN CLASS="regexccopen">]</SPAN><SPAN CLASS="regexspecial">*</SPAN></TT> and <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> are mutually exclusive when compiling your regular expression, and automatically make the star possessive.</p> <p>Now, linear backtracking like a regex with a single quantifier does is pretty fast. It鈥檚 unlikely you鈥檒l notice the speed difference. However, when you鈥檙e nesting quantifiers, a possessive quantifier may save your day. Nesting quantifiers means that you have one or more repeated tokens inside a group, and the group is also repeated. That鈥檚 when <A HREF="catastrophic.html" TARGET="_top">catastrophic backtracking</A> often rears its ugly head. In such cases, you鈥檒l depend on possessive quantifiers and/or <A HREF="atomic.html" TARGET="_top">atomic grouping</A> to save the day.</p> <h2>Possessive Quantifiers Can Change The Match Result</h2> <p>Using possessive quantifiers can change the result of a match attempt. Since no backtracking is done, and matches that would require a greedy quantifier to backtrack will not be found with a possessive quantifier. For example, <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN><SPAN CLASS="regexspecial">.</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexplain">"</SPAN></TT> matches <tt class=match>"abc"</tt> in <tt class=string>"abc"x</tt>, but <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN><SPAN CLASS="regexspecial">.</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexspecial">+</SPAN><SPAN CLASS="regexplain">"</SPAN></TT> does not match this string at all.</p> <p>In both regular expressions, the first <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> matches the first <tt class=match>"</tt> in the string. The repeated dot then matches the remainder of the string <tt class=match>abc"x</tt>. The second <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> then fails to match at the end of the string.</p> <p>Now, the paths of the two regular expressions diverge. The possessive dot-star wants it all. No backtracking is done. Since the <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> failed, there are no permutations left to try, and the overall match attempt fails. The greedy dot-star, while initially grabbing everything, is willing to give back. It will backtrack one character at a time. Backtracking to <tt class=match>abc"</tt>, <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> fails to match <tt class=string>x</tt>. Backtracking to <tt class=match>abc</tt>, <TT CLASS=syntax><SPAN CLASS="regexplain">"</SPAN></TT> matches <tt class=match>"</tt>. An overall match <tt class=match>"abc"</tt> is found.</p> <p>Essentially, the lesson here is that when using possessive quantifiers, you need to make sure that whatever you鈥檙e applying the possessive quantifier to should not be able to match what should follow it. The problem in the above example is that the dot also matches the closing quote. This prevents us from using a possessive quantifier. The negated character class in the previous section cannot match the closing quote, so we can make it possessive.</p> <h2>Using Atomic Grouping Instead of Possessive Quantifiers</h2> <p>Technically, possessive quantifiers are a notational convenience to place an <A HREF="atomic.html" TARGET="_top">atomic group</A> around a single quantifier. All regex flavors that support possessive quantifiers also support atomic grouping. But not all regex flavors that support atomic grouping support possessive quantifiers. With those flavors, you can achieve the exact same results using an atomic group.</p> <p>Basically, instead of <TT CLASS=syntax><SPAN CLASS="regexplain">X</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexspecial">+</SPAN></TT>, write <TT CLASS=syntax><SPAN CLASS="regexnest1">(?></SPAN><SPAN CLASS="regexplain">X</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexnest1">)</SPAN></TT>. It is important to notice that both the quantified token X and the quantifier are inside the atomic group. Even if X is a group, you still need to put an extra atomic group around it to achieve the same effect. <TT CLASS=syntax><SPAN CLASS="regexnest1">(?:</SPAN><SPAN CLASS="regexplain">a</SPAN><SPAN CLASS="regexnest1">|</SPAN><SPAN CLASS="regexplain">b</SPAN><SPAN CLASS="regexnest1">)</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexspecial">+</SPAN></TT> is equivalent to <TT CLASS=syntax><SPAN CLASS="regexnest1">(?></SPAN><SPAN CLASS="regexnest2">(?:</SPAN><SPAN CLASS="regexplain">a</SPAN><SPAN CLASS="regexnest2">|</SPAN><SPAN CLASS="regexplain">b</SPAN><SPAN CLASS="regexnest2">)</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexnest1">)</SPAN></TT> but not to <TT CLASS=syntax><SPAN CLASS="regexnest1">(?></SPAN><SPAN CLASS="regexplain">a</SPAN><SPAN CLASS="regexnest1">|</SPAN><SPAN CLASS="regexplain">b</SPAN><SPAN CLASS="regexnest1">)</SPAN><SPAN CLASS="regexspecial">*</SPAN></TT>. The latter is a valid regular expression, but it won鈥檛 have the same effect when used as part of a larger regular expression.</p> <p>To illustrate, <TT CLASS=syntax><SPAN CLASS="regexnest1">(?:</SPAN><SPAN CLASS="regexplain">a</SPAN><SPAN CLASS="regexnest1">|</SPAN><SPAN CLASS="regexplain">b</SPAN><SPAN CLASS="regexnest1">)</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexspecial">+</SPAN><SPAN CLASS="regexplain">b</SPAN></TT> and <TT CLASS=syntax><SPAN CLASS="regexnest1">(?></SPAN><SPAN CLASS="regexnest2">(?:</SPAN><SPAN CLASS="regexplain">a</SPAN><SPAN CLASS="regexnest2">|</SPAN><SPAN CLASS="regexplain">b</SPAN><SPAN CLASS="regexnest2">)</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexnest1">)</SPAN><SPAN CLASS="regexplain">b</SPAN></TT> both fail to match <tt class=string>b</tt>. <TT CLASS=syntax><SPAN CLASS="regexplain">a</SPAN><SPAN CLASS="regexnest2">|</SPAN><SPAN CLASS="regexplain">b</SPAN></TT> matches the <tt class=match>b</tt>. The star is satisfied, and the fact that it鈥檚 possessive or the atomic group will cause the star to forget all its backtracking positions. The second <TT CLASS=syntax><SPAN CLASS="regexplain">b</SPAN></TT> in the regex has nothing left to match, and the overall match attempt fails.</p> <p>In the regex <TT CLASS=syntax><SPAN CLASS="regexnest1">(?></SPAN><SPAN CLASS="regexplain">a</SPAN><SPAN CLASS="regexnest1">|</SPAN><SPAN CLASS="regexplain">b</SPAN><SPAN CLASS="regexnest1">)</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexplain">b</SPAN></TT>, the atomic group forces the alternation to give up its backtracking positions. This means that if an <tt class=match>a</tt> is matched, it won鈥檛 come back to try <TT CLASS=syntax><SPAN CLASS="regexplain">b</SPAN></TT> if the rest of the regex fails. Since the star is outside of the group, it is a normal, greedy star. When the second <TT CLASS=syntax><SPAN CLASS="regexplain">b</SPAN></TT> fails, the greedy star backtracks to zero iterations. Then, the second <TT CLASS=syntax><SPAN CLASS="regexplain">b</SPAN></TT> matches the <tt class=match>b</tt> in the subject string.</p> <p>This distinction is particularly important when converting a regular expression written by somebody else using possessive quantifiers to a regex flavor that doesn鈥檛 have possessive quantifiers. You could, of course, let a tool like <A HREF="regexbuddy.html" TARGET="_top">RegexBuddy</A> do the conversion for you.</p> <div id=cntmobi><p>| <a href='quickstart.html'>Quick Start</a> | <a href='tutorial.html'>Tutorial</a> | <a href='tools.html'>Tools & Languages</a> | <a href='examples.html'>Examples</a> | <a href='refflavors.html'>Reference</a> | <a href='books.html'>Book Reviews</a> |</p><p>| <a href='tutorial.html'>Introduction</a> | <a href='tutorialcnt.html'>Table of Contents</a> | <a href='characters.html'>Special Characters</a> | <a href='nonprint.html'>Non-Printable Characters</a> | <a href='engine.html'>Regex Engine Internals</a> | <a href='charclass.html'>Character Classes</a> | <a href='charclasssubtract.html'>Character Class Subtraction</a> | <a href='charclassintersect.html'>Character Class Intersection</a> | <a href='shorthand.html'>Shorthand Character Classes</a> | <a href='dot.html'>Dot</a> | <a href='anchors.html'>Anchors</a> | <a href='wordboundaries.html'>Word Boundaries</a> | <a href='alternation.html'>Alternation</a> | <a href='optional.html'>Optional Items</a> | <a href='repeat.html'>Repetition</a> | <a href='brackets.html'>Grouping & Capturing</a> | <a href='backref.html'>Backreferences</a> | <a href='backref2.html'>Backreferences, part 2</a> | <a href='named.html'>Named Groups</a> | <a href='backrefrel.html'>Relative Backreferences</a> | <a href='branchreset.html'>Branch Reset Groups</a> | <a href='freespacing.html'>Free-Spacing & Comments</a> | <a href='unicode.html'>Unicode</a> | <a href='modifiers.html'>Mode Modifiers</a> | <a href='atomic.html'>Atomic Grouping</a> | <a href='possessive.html'>Possessive Quantifiers</a> | <a href='lookaround.html'>Lookahead & Lookbehind</a> | <a href='lookaround2.html'>Lookaround, part 2</a> | <a href='keep.html'>Keep Text out of The Match</a> | <a href='conditional.html'>Conditionals</a> | <a href='balancing.html'>Balancing Groups</a> | <a href='recurse.html'>Recursion</a> | <a href='subroutine.html'>Subroutines</a> | <a href='recurseinfinite.html'>Infinite Recursion</a> | <a href='recurserepeat.html'>Recursion & Quantifiers</a> | <a href='recursecapture.html'>Recursion & Capturing</a> | <a href='recursebackref.html'>Recursion & Backreferences</a> | <a href='recursebacktrack.html'>Recursion & Backtracking</a> | <a href='posixbrackets.html'>POSIX Bracket Expressions</a> | <a href='zerolength.html'>Zero-Length Matches</a> | <a href='continue.html'>Continuing Matches</a> |</p></div> <div id=copyright> <P CLASS=copyright>Page URL: <A HREF="https://www.regular-expressions.info/possessive.html" TARGET="_top">https://www.regular-expressions.info/possessive.html</A><BR> Page last updated: 21 November 2022<BR> Site last updated: 06 November 2024<BR> Copyright © 2003-2024 Jan Goyvaerts. All rights reserved.</P> </div> </div> </div> </body></html>