--- id: 587d7db7367417b2b2512b9d title: Match Beginning String Patterns challengeType: 1 videoUrl: '' localeTitle: مباراة بداية أنماط سلسلة --- ## Description
أظهرت التحديات السابقة أنه يمكن استخدام التعبيرات العادية للبحث عن عدد من التطابقات. كما يتم استخدامها للبحث عن أنماط في مواضع محددة في السلاسل. في تحدي سابق ، استخدمت caret ( ^ ) داخل مجموعة character set لإنشاء مجموعة negated character set [^thingsThatWillNotBeMatched] في النموذج [^thingsThatWillNotBeMatched] . خارج مجموعة character set ، يتم استخدام caret للبحث عن الأنماط في بداية السلاسل.
let firstString = "Ricky is first and can be found."؛
let firstRegex = / ^ Ricky /؛
firstRegex.test (firstString)؛
// يعود صحيح
let notFirst = "لا يمكنك العثور على Ricky الآن."؛
firstRegex.test (notFirst)؛
// إرجاع خاطئة
## Instructions
استخدم caret في تعبير منطقي للبحث عن "Cal" فقط في بداية السلسلة rickyAndCal .
## Tests
```yml tests: - text: يجب أن يبحث التعبير المعتاد عن "Cal" بحرف كبير. testString: 'assert(calRegex.source == "^Cal", "Your regex should search for "Cal" with a capital letter.");' - text: يجب ألا يستخدم تعبيرك المعتاد أي أعلام. testString: 'assert(calRegex.flags == "", "Your regex should not use any flags.");' - text: يجب أن يتطابق تعبيرك العادي مع كلمة "Cal" في بداية السلسلة. testString: 'assert(calRegex.test("Cal and Ricky both like racing."), "Your regex should match "Cal" at the beginning of the string.");' - text: يجب ألا يتطابق التعبير العادي مع "Cal" في وسط سلسلة. testString: 'assert(!calRegex.test("Ricky and Cal both like racing."), "Your regex should not match "Cal" in the middle of a string.");' ```
## Challenge Seed
```js let rickyAndCal = "Cal and Ricky both like racing."; let calRegex = /change/; // Change this line let result = calRegex.test(rickyAndCal); ```
## Solution
```js // solution required ```