Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank, 10 Days Of JavaScript. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.
In this post, you will find the solution for Day 7: Regular Expressions III in JavaScript-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.
Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.
Introduction To JavaScript
JavaScript is a lightweight, cross-platform, and interpreted scripting language. It is well-known for the development of web pages, many non-browser environments also use it. JavaScript can be used for Client-side developments as well as Server-side developments. JavaScript contains a standard library of objects, like Array, Date, and Math, and a core set of language elements like operators, control structures, and statements.
Advantages of JavaScript
The merits of using JavaScript are −
- Less server interaction − You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.
- Immediate feedback to the visitors − They don’t have to wait for a page reload to see if they have forgotten to enter something.
- Increased interactivity − You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.
- Richer interfaces − You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.
Link for the Problem – Day 7: Regular Expressions III – Hacker Rank Solution
Day 7: Regular Expressions III – Hacker Rank Solution
Problem:
Task
Complete the function in the editor below by returning a RegExp object, , that matches every integer in some string .
Constraints
- The length of string is .
- It’s guaranteed that string contains at least one integer.
Output Format
The function must return a RegExp object that matches every integer in some string .
Sample Input 0
102, 1948948 and 1.3 and 4.5
Sample Output 0
102 1948948 1 3 4 5
Explanation 0
When we call match on string and pass the correct RegExp as our argument, it returns the following array of results: [ '102', '1948948', '1', '3', '4', '5' ]
.
Sample Input 1
1 2 3
Sample Output 1
1 2 3
Explanation 1
When we call match on string and pass the correct RegExp as our argument, it returns the following array of results: [ '1', '2', '3' ]
.
Day 7: Regular Expressions III – Hacker Rank Solution
function regexVar() { // Declare a RegExp object variable named 're' // It must match ALL occurrences of numbers in a string. let re = /\d+/g; return re; }