Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 383cae9

Browse files
Chore: Activity-1 Completed for Day-19
1 parent 1e8371c commit 383cae9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎Day19/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
console.log("-------------------------------------------------");
22
console.log("Activity 1: ");
33

4+
// Task 1: Write a regular expression to match a simple pattern (e.g., match all occurrences of the word "JavaScript" in a string). Log the matches.
5+
6+
let pattern = /JavaScript/g;
7+
let str = "JavaScript is a scripting language. JavaScript is used for web development. JavaScript makes web pages interactive.";
8+
let matches = str.match(pattern);
9+
10+
console.log(matches);
11+
12+
// Task 2: Write a regular expression to match all digits in a string. Log the matches.
13+
14+
pattern = /\d/g;
15+
str = "There are 12 months in a year.";
16+
matches = str.match(pattern);
17+
18+
console.log(matches);
419

520

621
console.log("-------------------------------------------------");

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /