Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Regular expression
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Assertions=== {| id="lookbehind" class="floatright wikitable" |- ! Assertion !! Lookbehind !! Lookahead |- ! Positive | style="text-align:center;font-size:125%;"|<code>(?'''<='''{{box|inline=yes|span=yes|type=black|radius=1ex|padding=0 0.5ex|font size=80%|pattern}})</code> | style="text-align:center;font-size:125%;"|<code>(?'''='''{{box|inline=yes|span=yes|type=black|radius=1ex|padding=0 0.5ex|font size=80%|pattern}})</code> |- ! Negative | style="text-align:center;font-size:125%;"|<code>(?'''<!'''{{box|inline=yes|span=yes|type=black|radius=1ex|font size=80%|padding=0 0.5ex|pattern}})</code> | style="text-align:center;font-size:125%;"|<code>(?<span style="padding:1px;">'''!'''</span>{{box|inline=yes|span=yes|type=black|radius=1ex|padding=0 0.5ex|font size=80%|pattern}})</code> |- | colspan="3"|Lookbehind and lookahead assertions<br/>in [[Perl]] regular expressions |} Other features not found in describing regular languages include assertions. These include the ubiquitous {{code|^}} and {{code|$}}, used since at least 1970,<ref>{{cite book |last1=Ritchie |first1=D. M. |last2=Thompson |first2=K. L. |title=QED Text Editor |url=http://cm.bell-labs.com/cm/cs/who/dmr/qedman.pdf |id=MM-70-1373-3 |date=June 1970 |access-date=2022-09-05 |archive-date=2015-02-03 |archive-url=https://wayback.archive-it.org/all/20150203071645/http://cm.bell-labs.com/cm/cs/who/dmr/qedman.pdf |url-status=dead}} Reprinted as "QED Text Editor Reference Manual", MHCC-004, Murray Hill Computing, Bell Laboratories (October 1972).</ref> as well as some more sophisticated extensions like lookaround that appeared in 1994.{{r|perl5}} Lookarounds define the surrounding of a match and do not spill into the match itself, a feature only relevant for the use case of string searching.{{citation needed|date=June 2023}} Some of them can be simulated in a regular language by treating the surroundings as a part of the language as well.<ref>{{cite web |author=Wandering Logic |title=How to simulate lookaheads and lookbehinds in finite state automata? |url=https://cs.stackexchange.com/a/40058 |website=Computer Science Stack Exchange |access-date=24 November 2019 |archive-date=7 October 2020 |archive-url=https://web.archive.org/web/20201007183206/https://cs.stackexchange.com/questions/2557/how-to-simulate-backreferences-lookaheads-and-lookbehinds-in-finite-state-auto/40058 |url-status=live}}</ref> The {{visible anchor |look-ahead assertions}} {{nowrap|1=<code>(?=...)</code>}} and {{nowrap|<code>(?!...)</code>}} have been attested since at least 1994, starting with Perl 5.<ref name=perl5>{{cite web |last=Wall |first=Larry |title=Perl 5: perlre.pod |url=https://github.com/Perl/perl5/blob/a0d0e21ea6ea90a22318550944fe6cb09ae10cda/pod/perlre.pod |date=1994-10-18 |website=GitHub}}</ref> The lookbehind assertions {{nowrap|1=<code>(?<=...)</code>}} and {{nowrap|<code>(?<!...)</code>}} are attested since 1997 in a commit by Ilya Zakharevich to Perl 5.005.<ref>{{cite web |last=Zakharevich |first=Ilya |title=Jumbo Regexp Patch Applied (with Minor Fix-Up Tweaks): Perl/perl5@c277df4 |url=https://github.com/Perl/perl5/commit/c277df42229d99fecbc76f5da53793a409ac66e1 |website=GitHub |date=1997-11-19}}</ref><!-- I emailed Ilya Zakharevich to confirm, and he confirmed that he came up with the notation. -->
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Regular expression
(section)
Add topic