Wikipedia talk:WikiProject JavaScript: Difference between revisions
Content deleted Content added
→What the script is supposed to do: not double-escaped, so no slashes |
|||
Line 245:
:What you could use instead is <code>var patt3 = new RegExp("\\*{"+(RegExp.$1.length+1)+"}");</code> which, for example, will give you the regex <code>/\*{3}/</code> when the <code>RegExp.$1</code> match is "**" - <u>'''[[User:Evad37|Evad]]''37'''''</u> <span style="font-size:95%;">[[[d:w:User talk:Evad37|talk]]]</span> 04:59, 7 May 2017 (UTCt)
:: {{ping|Evad37}} I'll try it and will let you know how it works. By the way, what about <code>var patt3 = new RegExp("$1\*");</code>. Why won't that work? (That was the first thing I tried, before going literal). [[User talk:The Transhumanist|<i>The Transhumanist</i>]] 23:14, 7 May 2017 (UTC)
:::<code>$1</code> as part of a string doesn't have any special meaning, except within the string .replace function. So <code>var patt3 = new RegExp("$1\*");</code> would give you the regex <code>/$1
== Use of Wikipedian programmer categories ==
|