Usage of Regular Expression g in javascript

     In regular expression g is used for global search. If you not use this g that expression only search and find with the first match. More details shown in the following example.



     str.replace(/s/g,"#");


Example Program:- (Editor)


Editor is Loading...

Advertisement

Related Posts:

  • do ... while in javascript      The do...while statement creates a loop that executes a specified statement until the test condition evaluates to false. Th… Read More
  • break in javascript      The break statement totally break the loop, in the following example write a for loop for execute 10 times but when the i v… Read More
  • Label and Break in javascript      Any identifier can use as label name. We can use a label to identify a loop and use the break statements to interrupt the e… Read More
  • while loop in javascript      The while statement creates a loop that executes a specified statement as long as the test condition evaluates to true. The… Read More
  • continue in javascript      continue is used to terminate the current iteration of the loop. If will not terminate the control from the whole loop just… Read More

0 nhận xét:

Đăng nhận xét