

#GSWITCH AND TRIANGLE GENERATOR#
A short */ 00053 /* overview appears in "Triangle: Engineering a 2D Quality Mesh */ 00054 /* Generator and Delaunay Triangulator," in Applied Computational */ 00055 /* Geometry: Towards Geometric Engineering, Ming C.

*/ 00048 /* These references are available for downloading from the Web page */ 00049 /* */ 00050 /* */ 00051 /* */ 00052 /* Three papers discussing aspects of Triangle are available. */ 00046 /* */ 00047 /* Some of the references listed below are marked with an asterisk.
#GSWITCH AND TRIANGLE CODE#
(If you are not directly supplying this code to a */ 00037 /* customer, and you are instead telling them how they can obtain it for */ 00038 /* free, then you are not required to make any arrangement with me.) */ 00039 /* */ 00040 /* Hypertext instructions for Triangle are available on the Web at */ 00041 /* */ 00042 /* */ 00043 /* */ 00044 /* Disclaimer: Neither I nor Carnegie Mellon warrant this code in any way */ 00045 /* whatsoever. Distribution of this code as */ 00035 /* part of a commercial system is permissible ONLY BY DIRECT ARRANGEMENT */ 00036 /* WITH THE AUTHOR. You may distribute modified versions of this code UNDER */ 00031 /* THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE */ 00032 /* SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH SOURCE */ 00033 /* AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR */ 00034 /* NOTICE IS GIVEN OF THE MODIFICATIONS. Private, research, and institutional */ 00030 /* use is free. You may get different output when you run this program. generate a random digit between 0 and 9Ĭonst new_text = text.replace(pattern, generateRandomDigit) You can also pass a function (instead of a string) as the second parameter to the replace() method. Pattern = /javascript/gi // case-insensitive and global searchĮxample 4: Passing Function as a Replacement all occurrences of javascript is replaced

Let new_text = text.replace(pattern, "JS") Let pattern = /javascript/i // case-insensitive search

the first occurrence of javascript is replaced Example 3: Case-Insensitive Replacement const text = "javaSCRIPT JavaScript" To perform the case-insensitive replacement, you need to use a regex with a i switch (case-insensitive search). Replace Without Considering Uppercase/Lowercase Here, the replace() method replaces both occurrences of Java with JavaScript. notice the g switch in the regex patternĬonst new_text = text.replace(pattern, "JavaScript") To replace all occurrences of the pattern, you need to use a regex with a g switch (global search). In both replace() methods, the first occurrence of Java is replaced with JavaScript. New_text = text.replace(pattern, "JavaScript") passing a regex as the first parameter Let new_text = text.replace(pattern, "JavaScript") passing a string as the first parameter
