The CreatorCon Call for Content is officially open! Get started here.

Recognize \ as string

tsoct
Tera Guru

How can I include \ as part of the string? 

var A = '/^' + iprefix + '\[0-9A-Z]{' + inumb + '}$/';
 
From the logs, A was returned as '/^AT[0-9A-Z]{18}$/' where '\' is missing.
1 ACCEPTED SOLUTION

CezaryBasta
Tera Guru

Use double \\. In this way you will mark \ as escaped character.

See chapter 1.1 here for more explanations.

--
See more of my content here.

View solution in original post

2 REPLIES 2

CezaryBasta
Tera Guru

Use double \\. In this way you will mark \ as escaped character.

See chapter 1.1 here for more explanations.

--
See more of my content here.

Sandeep Rajput
Tera Patron
Tera Patron

@tsoct Please update the var A as follows.

 

var A = '/^' + iprefix + '\\[0-9A-Z]{' + inumb + '}$/';