JavaScript code that removes character spaces and converts characters

Source: Internet
Author: User

The program can convert characters, remove spaces in the middle of the characters, and click Bttton to copy the code. Further improvement is required. Please kindly advise. The left and right spaces functions are not completed.

Example:

<HTML> <HEAD> <TITLE> character handler </TITLE> </HEAD> <BODY bgColor = # bbccdd> <script language = "javascript" type = "text/javascript "> String. prototype. replaceAll = stringReplaceAll; function stringReplaceAll (AFindText, ARepText) {var raRegExp = new RegExp (AFindText. replace (/([\ (\) \ [\] \ {\} \ ^ \ $ \ + \-\*\? \. \ "\ '\ | \/\])/G," \ $1 ")," ig "); return this. replace (raRegExp, ARepText);} function myreplace () {var content = document. getElementById ("content "). value; var qa = document. getElementById ("tr "). value; var va = document. getElementById ("tp "). value; var rel_con = content. replaceAll (qa, va); while (rel_con.indexOf ("")! =-1) {rel_con = rel_con.replace ("", "");} document. getElementById ("content2 "). value = rel_con; // run the copy code var e = document. getElementById ("ct"); // The object is cte. select (); // select the object document.exe cCommand ("Copy"); // execute the browser Copy command} </SCRIPT> <HR color = red> <BR> <LI> remove space, escape Character <BR> <INPUT id = content value = "| a maxim | y World" name = contxt> <BR> <br> to be converted: <INPUT value = "|" id = tr name = contxt> <br> convert to a character: <INPUT id = tp value = "comment" name = contxt> <BR> <br> <textarea rows = "5" name = "ct" id = content2 cols = "50" style = "color: green ">... </textarea> <br> <INPUT onclick = myreplace () type = button value = "convert and copy this code"> <br> </BODY> </HTML> <br/> <center> If the effect cannot be displayed, press Ctrl + F5 to refresh the page. For more webpage code: <a href =' http://www.bkjia.com/ 'Target = '_ blank'> http://www.bkjia.com/ </A> </center>

Tip: the code can be modified before running!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.