test method in JavaScript regular expressions

In this lesson, we will look at the test method, which checks if a string contains at least one match with a regex. If there is, true is returned, and if not, false. The method takes a string as a parameter, and is applied to a regex, like this:

javascriptregex.test(where to search)

For example, let's check some string for compliance with a regex:

javascript/a+/.test('eee aaa bbb'); // returns true

Often this method is used to check if a regular expression matches an entire string. In this case, at the beginning of the regex they put a hat, and at the end - a dollar:

javascript/^a+$/.test('aaaaaaaaa'); // returns true
Задание 1

Determine whether a passed string starts with 'http://'.

Задание 2

Determine whether a passed string begins with 'http://' or 'https://'.

Задание 3

Determine whether a passed string ends with the extension 'txt', 'html', or 'php'.

Задание 4

Determine whether a passed string ends with the extension 'jpg' or 'jpeg'.

Задание 5

Determine whether a passed string ends with the extension 'jpg', 'jpeg', or 'png'.

Задание 6

Determine whether a passed string is 'a number having from 1 to 12 digits'.

Задание 7

Determine whether a passed string is a date in the year-month-day format.

Задание 8

Determine whether a passed string is a date in the day.month.year format.

Задание 9

Determine whether a passed string is a time in the hours:minutes:seconds format.

Задание 10

Determine whether a passed string is a valid email.

Задание 11

Determine whether a passed string is a domain name.