Reputation: 2247
I currently have the following regex
(?!\(\) => )test\(.*,.*\)
But I would only like it to match
test("Test 1", () { expect(1, equals(1)); });
And not
test(test, () { expect(test, "Test3"); }) )
from the following text
import 'package:unittest/unittest.dart';
main() {
testExecuter("fileName", test, () => $0 );
test("Test 1", () { expect(1, equals(1)); });
var tests = ["Test2", "Test3"];
for (var test in tests) {
testExecuter("fileName", test, () => test(test, () { expect(test, "Test3"); }) );
}
}
I am using regexpal.com to test it for some reason the part of the regex saying not to begin with () => is not working
Upvotes: 0
Views: 58
Reputation: 336158
You're using a lookahead assertion when you should be using a lookbehind assertion:
(?<!\(\) => )test\(.*,.*\)
After all, "test(test, ()..."
does in fact not begin with "() => "
- it is preceded by it, hence you need to look "behind" the current position.
Upvotes: 1