Skip to content

Sets and ranges #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Answers: **no, yes**.
উত্তর: **না, হ্যাঁ**।

- In the script `subject:Java` it doesn't match anything, because `pattern:[^script]` means "any character except given ones". So the regexp looks for `"Java"` followed by one such symbol, but there's a string end, no symbols after it.
- `subject:Java` এ কোন কিছুর সাথে ম্যাচ হবেনা, কারন `pattern:[^script]` দ্বারা বুঝায় "প্রদত্ত ক্যারাক্টার ব্যতীত যেকোন ক্যারাক্টার"। সুতরাং রেগুলার এক্সপ্রেশনটি `"Java"` এর পর যেকোন একটি ক্যারাক্টার খুঁজে, কিন্তু স্ট্রিংটির শেষে কোন ক্যারাক্টার নেই।

```js run
alert( "Java".match(/Java[^script]/) ); // null
```
- Yes, because the part `pattern:[^script]` part matches the character `"S"`. It's not one of `pattern:script`. As the regexp is case-sensitive (no `pattern:i` flag), it treats `"S"` as a different character from `"s"`.
- হ্যাঁ, কারণ `pattern:[^script]` অংশটি `"S"` ক্যারাক্টারের সাথে ম্যাচ করে। `"S"` ক্যারাক্টারটি `pattern:script` এর মধ্যে নেই। যেহেতু রেগুলার এক্সপ্রেশন কেস-সেনসিটিভ (কোন `pattern:i` ফ্ল্যাগ নেই), তাই ক্যারাক্টার `"S"` এবং `"s"` কে আলাদা হিসেবে বিবেচনা করে।

```js run
alert( "JavaScript".match(/Java[^script]/) ); // "JavaS"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Java[^script]

We have a regexp `pattern:/Java[^script]/`.
আমাদের এ ধরণের একটি প্যাটার্ন আছে `pattern:/Java[^script]/`

Does it match anything in the string `subject:Java`? In the string `subject:JavaScript`?
এটি কি এই স্ট্রিংয়ের `subject:Java` সাথে ম্যাচ হবে? অথবা এই স্ট্রিংয়ের `subject:JavaScript`?
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Answer: `pattern:\d\d[-:]\d\d`.
উত্তর: `pattern:\d\d[-:]\d\d`.

```js run
let regexp = /\d\d[-:]\d\d/g;
alert( "Breakfast at 09:00. Dinner at 21-30".match(regexp) ); // 09:00, 21-30
```

Please note that the dash `pattern:'-'` has a special meaning in square brackets, but only between other characters, not when it's in the beginning or at the end, so we don't need to escape it.
দয়া করে মনে রাখা উচিত তৃতীয় বন্ধনীতে ড্যাশ `pattern:'-'` এর স্পেশাল অর্থ আছে, কিন্তু যদি দুটি ক্যারাক্টারের মাঝে ব্যবহার করি, কিন্তু শুরুতে অথবা শেষে ড্যাশ-ই বুঝায়, সুতরাং আমাদের এটি এস্কেপ করার প্রয়োজন নেই।
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Find the time as hh:mm or hh-mm
# সময় খুঁজা hh:mm অথবা hh-mm

The time can be in the format `hours:minutes` or `hours-minutes`. Both hours and minutes have 2 digits: `09:00` or `21-30`.
সময়ের ফরম্যাট হতে পারে এভাবে `hours:minutes` অথবা `hours-minutes`. ঘন্টা এবং মিনিট উভয়েই দুই ডিজিটের হয়: `09:00` অথবা `21-30`.

Write a regexp to find time:
উপরোল্লিখিত ফরম্যাটে সময় খুঁজার জন্য প্যাটার্ন লিখুন:

```js
let regexp = /your regexp/g;
alert( "Breakfast at 09:00. Dinner at 21-30".match(regexp) ); // 09:00, 21-30
```

P.S. In this task we assume that the time is always correct, there's no need to filter out bad strings like "45:67". Later we'll deal with that too.
বি.দ্র. দুই ডিজিটের যেকোন সময় সঠিক হিসেবে বিবেচনা করতে পারি, আমাদের স্ট্রিং ভ্যালিডেশন নিয়ে চিন্তিত হতে হবে না যেমন "45:67"। পরবর্তীতে আমরা এটিও দেখব।
Loading