javascript eval function implementation using regular expressions to remove carriage returns, line feeds and comments

2010-12-24  来源:本站原创  分类:Web  人气:154 

var txtValue = document.getElementById (txtId). value;
txtValue = txtValue.replace (/ \ / \ * ((\ n | \ r |.)*?) \ * \ / / mg, ""); / / remove multi-line comments /*..*/
txtValue = txtValue.replace (/ (\ s +) \ / \ /(.*) \ n / g ,""); / / remove the single line comment / / (spaces in front of the note)
txtValue = txtValue.replace (/; \ / \ /(.*) \ n / g ,";"); / / remove the single line comment / / (the comment in front of a semi-colon)
txtValue = txtValue.replace (/ \ / \ /[^"][^'] \ n / g ,""); / / remove only one line comment //(// back 'or a "non-replacement)
txtValue = txtValue.replace (/ [\ r] / g ,""); / / replace line
txtValue = txtValue.replace (/ [\ n] / g ,""); / / replace carriage return
eval (txtValue);

相关文章
  • javascript eval function implementation using regular expressions to remove carriage returns, line feeds and comments 2010-12-24

    var txtValue = document.getElementById (txtId). value; txtValue = txtValue.replace (/ \ / \ * ((\ n | \ r |.)*?) \ * \ / / mg, ""); / / remove multi-line comments /*..*/ txtValue = txtValue.replace (/ (\ s +) \ / \ /(.*) \ n / g ,"");

  • In-depth understanding of javascript eval function (Reprinted) 2010-05-07

    Found to be an appropriate title since this is not so easy, huh, huh, so in this note under the first two purposes of this article: (1) Introduction javascript eval function in the use of (2) how to function in the implementation of the global code ►

  • javascript eval function 2010-08-25

    Chance to see the direct implementation using a window handle js js fragment approach finds this method very good. 1. Now we see why the need this way: When we need from the server dynamically, or dynamically generated on the client side js code for

  • PHP regular expressions used - remove non-printing characters 2010-10-29

    Regular Expression Study Notes Regular expression (regular expression) describes a string matching pattern, can be used to check whether a string contains a substring, the substring will be replaced by matching or remove from a string of substring ma

  • Using regular expressions to remove HTML tags in Web pages 2010-10-13

    After crawling a page of data (such as description), if as it was displayed, it may be because it contains HTML tags not closed but disrupted the format may also be compared with people in it "incomprehensible" the HTML tags to upset the form bo

  • MySQL application of regular expressions 2011-03-19

    A regular expression is specified for the complex pattern of powerful search methods. MySQL uses Henry Spencer's implementation of regular expressions, the goal is in line with POSIX 1003.2. MySQL uses the extended version to support SQL statements u

  • Eval function in Javascript in the use of 2010-07-19

    Javascript Eval function using JavaScript there are many small tricks to make programming easier. One is the eval () function, this function can be a string as a JavaScript expression to execute it the same. Give a small example var the_unevaled_answ

  • In-depth understanding of the eval function in javascript 2010-09-07

    Reprinted from: http://wanyij.blog.51cto.com/46570/43794 In-depth understanding of the eval function in javascript Category: Technology Zone :2007-5-21 15:04:58 author: supNate Found to be an appropriate title since this is not so easy, huh, huh, so

  • Check the form of regular expressions 2010-03-16

    Check your phone or phone number: Rules of domestic fixed-line and fax the basic format of the code are connected with the 0 symbol "-" + telephone number, in addition to possible extension, code in 3, 4, phone numbers are 7 and 8 a; other forma

  • Collection of PHP regular expressions examples 2010-03-25

    2008-04-13 15:32 / / intercept the middle of the string method preg_match ('/(?: ello )(.*)/', 'hello biafra', $ match); print_r ($ match); Array ( [0] => ello biafra [1] => biafra ) preg_match ('/ (ello )(.*)/',' hello biafra ', $ match); print_r (

  • Proficient in JS regular expressions 2010-07-26

    Regular expressions can be: • Test a string to a pattern. For example, an input string can be tested to see whether the string model there is a phone number or a credit card number pattern. This is called data validation • Replace the text. May in th

  • JS regular expressions API 2010-08-26

    What are regular expressions? This problem can be found: " Regular Expression Tutorial 30 minutes ", and many programming languages support regular expressions, this paper discussed only in JavaScript regular expressions. Create a regular expres

  • Examples of regular expressions 2010-11-14

    Regular expressions - Case Study (updated 2009-03-10) Keywords: regular expression (1) Application: calculation of the string length (the length of a double-byte character count 2, ASCII characters and 1) String.prototype.len = function () {return th

  • Learning regular expressions (a) 2011-05-16

    1. What is a regular expression Basically, the regular expression is used to describe a certain number of text mode. Regex representatives Regular Express. This article will use the <<regex>> to indicate a specific regular expression. A text i

  • oracle 10g support for regular expressions 2011-05-24

    Recently adjusted the table structure, so site_id for the number (9), found that some of the testing process includes i_site_id INTEGER (2); Such a statement, lead site_id error when more than two The use plsql developer's find data objects of the re

  • PHP regular expressions to use notes 2011-01-04

    Detailed PHP regular expressions Operator Description \ Escape character (), (?:), (?=), [] Parentheses and brackets *, +,?, {N}, {n,}, {n, m} qualifier ^, $, \ Anymetacharacter location and sequence | "Or" symbolic interpretation of the charact

  • oracle 10g supports regular expressions 2011-05-24

    Recently adjusted the table structure, so site_id for the number (9), found in some of the testing process includes i_site_id INTEGER (2); This statement led to site_id error when more than two The use plsql developer's find data objects of regular e

  • javascript tips: (function (){})() 2008-08-19

    javascript tips: (function (){})() Such as the title. This is actually a line function calls, and callamethod () is no different. (function (){}) is an anonymous closure, (function (){})() is called closure, of course, where parameters are empty. We

  • Are the positive pre-check (regular expressions non-relationship) 2010-04-10

    Non-matching with (?! Exp) Matching non-"non-content" of expression should be written :^(?!.* non-content) .* $ 1. Regular expressions in square brackets except among the [^] that do not accept the character set, or ^ that match the beginning of

  • Usage of grep: grep and regular expressions 2010-07-29

    First thing to remember is: regular expressions and wildcards are not, they are not the same as the meaning of that! Regular expression is just a representation, as long as the tools to support this representation, then the tool can handle the regula