Skip to content

Instantly share code, notes, and snippets.

@uprime22
Last active July 22, 2016 00:48
Show Gist options
  • Save uprime22/bc641275166f2c827f9dc7c168647ccb to your computer and use it in GitHub Desktop.
Save uprime22/bc641275166f2c827f9dc7c168647ccb to your computer and use it in GitHub Desktop.
表示される文字列と、文字列データと、文字列リテラルを区別する必要を示す一例。 関数T.currentで得られる文字列データは、 引用符を抜いた文字列リテラル、と同じに見なしてはいけない。 エスケープ済みの文字列リテラルと同等とみなすべき。
// Textwellの現在行にテスト用文字列"\s \n "などを置き、実行。
var str = '\\s \\n test';
var crt = T.current;
var ptn1 = RegExp(str,'g');
var ptntxt= ptn1.toString();
var ptn2 = RegExp(crt,'g');
var crttxt = ptn2.toString();
alert('文字列リテラル:\"\\\\s \\\\n test\"\n' + ptntxt + '\n\nT.current\n'+ crttxt );
T('done');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment