Understanding Online Editor Features for Viewing Regular Expressions

Asked 2 years ago, Updated 2 years ago, 121 views

Regular expression apostrophei also want to match as part of the string. In relation to , I can now escape the single quote with the following code:However, on repl.it, which I use,

/[w']+/g
['Hell\'o', 'World']
/[^s]+/g
['Hell\'o', 'World']

appears.Some online editors have to interpret it as if it were escaping.Is there a question (called rending artifact) in the online editor that makes it easier for beginners of regular expressions to misunderstand such things as escape?

function printWords(str){
  var count = 0;
  vararr=str.match(/[\w']+/g);
  console.log("/[\w']+/g\n",arr);
}
printWords ("Hell'o World");

function printWordss(str){
  var count = 0;
  vararr=str.match(/[^\s]+/g);
  console.log("/[^\s]+/g\n",arr);
}
printWordss ("Hell'o World") 

edit1:

From the comments of respondents at https://stackoverflow.com/questions/40006095/escaping-regex-single-quote-creates-extra-backslashes-on-repl-it to the term rendering artifact.

javascript regular-expression

2022-09-30 21:29

1 Answers

According to Nekketsuuuu's comment, repl.it uses a character literal like single quote as artifact, matches it in regular expressions, and then treats single quote as a string as rendering artifact.The question was, is it common in online editors to use rendering artifact as a regular expression?

Below is an excerpt from the link above.

semantics of artifact in software engineering

Ingraphics programming, its used to reference part of an image
that did not render correctly.For example, if a small piece of a
Previous frame or view is still left on screen after drawing is done,
that'd be referred to as an artifact.

rendering artifact in repl.it

That's a rendering art of how the REPL you are using presents a
US>string when it displays a string as the result of your
code.


2022-09-30 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.