Don't use regex to parse ^
diff --git a/lib/src/patterns.dart b/lib/src/patterns.dart
index 59b0c09..8b32900 100644
--- a/lib/src/patterns.dart
+++ b/lib/src/patterns.dart
@@ -18,5 +18,5 @@
/// a string.
final START_COMPARISON = new RegExp(r"^[<>]=?");
-/// Parses the "compatible with" operator ("^") at the beginning of a string.
-final START_COMPATIBLE_WITH = new RegExp(r"^\^");
+/// The "compatible with" operator.
+const COMPATIBLE_WITH = "^";
diff --git a/lib/src/version_constraint.dart b/lib/src/version_constraint.dart
index 38864aa..cb1c64c 100644
--- a/lib/src/version_constraint.dart
+++ b/lib/src/version_constraint.dart
@@ -91,22 +91,20 @@
// Try to parse the "^" operator followed by a version.
matchCompatibleWith() {
- var compatibleWith = START_COMPATIBLE_WITH.firstMatch(text);
- if (compatibleWith == null) return null;
+ if (!text.startsWith(COMPATIBLE_WITH)) return null;
- var op = compatibleWith[0];
- text = text.substring(compatibleWith.end);
+ text = text.substring(COMPATIBLE_WITH.length);
skipWhitespace();
var version = matchVersion();
if (version == null) {
- throw new FormatException('Expected version number after "$op" in '
- '"$originalText", got "$text".');
+ throw new FormatException('Expected version number after '
+ '"$COMPATIBLE_WITH" in "$originalText", got "$text".');
}
if (text.isNotEmpty) {
throw new FormatException('Cannot include other constraints with '
- '"^" constraint in "$originalText".');
+ '"$COMPATIBLE_WITH" constraint in "$originalText".');
}
return new VersionConstraint.compatibleWith(version);