┌──┬───┬──┬───┬──┬───┬──┬───┬──┬───┬──┬───┬──┬───┬──┬───┬──┐S = │e1│ A │e2│ B │e3│ h │e4│ e │e5│ d │e6│ e │e7│ C │e8│ D │e9│└──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┴───┴──┘
index 0 1 2 3 4 5 6 7
$ txr -c '@(repeat)@{nothede /a.*z&~.*hede.*/}@(do (put-line nothede))@(end)' -az <- echoedazabcz <- echoedabczabhederz <- not echoed; contains hedeahedez <- not echoed; contains hedeace <- not echoed; does not end in zahedz <- echoedahedz
var _ = regexGen;
var regex = _(_.startOfLine(),_.anything().notContains( // match anything that not contains:_.anything().lazy(), 'hede' // zero or more chars that followed by 'hede',// i.e., anything contains 'hede'),_.endOfLine());
Regex Hero is a real-time online Silverlight Regular Expression Tester.XRegex Hero is a real-time online Silverlight Regular Expression Tester.Regex HeroRegex HeroRegex HeroRegex HeroRegex Hero is a real-time online Silverlight Regular Expression Tester.Regex Her Regex Her Regex Her Regex Her Regex Her Regex Her Regex Hero is a real-time online Silverlight Regular Expression Tester.Regex Her is a real-time online Silverlight Regular Expression Tester.Regex Heroegex Hero egex Hero egex Hero egex Hero egex Hero egex Hero Regex Hero is a real-time online Silverlight Regular Expression Tester.RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRegex Hero is a real-time online Silverlight Regular Expression Tester.
Regex Heregex Heroegex Hero is a real-time online Silverlight Regular Expression Tester.Regex Her is a real-time online Silverlight Regular Expression Tester.Regex Her Regex Her Regex Her Regex Her Regex Her Regex Her is a real-time online Silverlight Regular Expression Tester.Nobody is a real-time online Silverlight Regular Expression Tester.Regex Her o egex Hero Regex Hero Reg ex Hero is a real-time online Silverlight Regular Expression Tester.
结果:
结果是每秒迭代次数作为3次运行的中位数-更大的数字=更好
01: ^((?!Regex Hero).)*$ 3.914 // Accepted Answer02: ^(?:(?!Regex Hero).)*$ 5.034 // With Non-Capturing group03: ^(?!.*?Regex Hero).* 7.356 // Lookahead at the beginning, if not found match everything04: ^(?>[^R]+|R(?!egex Hero))*$ 6.137 // Lookahead only on the right first letter05: ^(?>(?:.*?Regex Hero)?)^.*$ 7.426 // Match the word and check if you're still at linestart06: ^(?(?=.*?Regex Hero)(?#fail)|.*)$ 7.371 // Logic Branch: Find Regex Hero? match nothing, else anything
P1: ^(?(?=.*?Regex Hero)(*FAIL)|(*ACCEPT)) ????? // Logic Branch in Perl - Quick FAILP2: .*?Regex Hero(*COMMIT)(*FAIL)|(*ACCEPT) ????? // Direct COMMIT & FAIL in Perl
Target the rest (the unmarked strings: e.g. lines without hede). Suppose you want to keep only the target and delete the rest (as you want):
s/^🔒.*//g
For a better understanding
Suppose you want to delete the target:
Mark the negative match: (e.g. lines with hede), using a character not included in the whole text at all. An emoji could probably be a good choice for this purpose.
s/(.*hede)/🔒\1/g
Target the rest (the unmarked strings: e.g. lines without hede). Suppose you want to delete the target: