Technology Programming

How to Get Rid of the Slash Before an Apostrophe in HTML

    • 1). Launch an HTML editor or Notepad.

    • 2). Open an HTML document and place this JavaScript code in its "head" section:

      <script type="text/javascript">

      function removeSlash(textString, replaceWith) {

      var target = "/'";

      var replacementString = "'";

      var apostrophe = "'";

      if (replaceWith != undefined) {

      target = "/" + replaceWith;

      replacementString = replaceWith;

      }

      var newString = testString.replace(new RegExp(target, 'g'), replacementString);

      return newString;

      }

      var testString = "12/'34/'56/2";

      var result = removeSlash(testString);

      alert(result);

      </script>

      The "removeSlash" function accepts a text string as a parameter. It then creates a new "RegExp" object used to remove all slashes that appear before apostrophes. The three lines of code after the function allow you to test the function by passing it the value stored in the testString variable.

    • 3). Save your document and view it in a browser. The JavaScript function processes the string containing the slash before the apostrophe, removes the slash and displays the resulting string.

Related posts "Technology : Programming"

How LiteData Creates Better Sites For Their Clients

Programming

Contrastive analysis of methodologies of test design for functional testing

Programming

A Proper Diet That Is Filled With Healthy Fats Can Help You Lose Weight

Programming

How to Create an Array of Objects in PHP

Programming

How to read character information from the World of Warcraft servers.

Programming

7 Ways To Master Ayurvedic Medicine For Constipation Without Breaking A Sweat

Programming

Web Design Company Kolkata for Seamless Ecommerce Site

Programming

What Happened to "Borland Delphi"? What is CodeGear? What is Embarcadero?

Programming

How to Send Pages to iFrame

Programming

Leave a Comment