Wikipedia talk:WikiProject JavaScript: Difference between revisions
Content deleted Content added
→top: add shortcut |
reply |
||
Line 247:
:: {{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*/</code>. To use the actual match instead of $1, you would use <code>var patt3 = new RegExp(RegExp.$1 + "\*");</code> which would e.g. give you the regex <code>/***/</code> for a match "**". To actually get valid regex, the match would have to be escaped (note also that the single slash in <code>"\*"</code> doesn't get preserved unless it is double-escaped as <code>"\\*"</code>) . - <u>'''[[User:Evad37|Evad]]''37'''''</u> <span style="font-size:95%;">[[[d:w:User talk:Evad37|talk]]]</span> 23:55, 7 May 2017 (UTC)
:::: {Thank you [[User:Evad37|Evad]]. Using your code, the script now works, matching about 90% of what it is supposed to. So far, I've cleaned up the all the country outlines for Africa. Now working on Asia. I'm not sure why it is skipping some that it shouldn't, but I'm sure I'll figure it out by observing as I use it. [[User talk:The Transhumanist|<i>The Transhumanist</i>]] 22:39, 11 May 2017 (UTC)
== Use of Wikipedian programmer categories ==
|