Click here to Skip to main content
14,931,811 members

Comments by usernamekiran (Top 3 by date)

usernamekiran 30-Aug-20 0:01am View
   
The following code got compiled, but it didn't do any changes at all to the aforementioned edited examples.
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
	{
		Skip = false;
		Summary = "test";
			Match m = Regex.Match(ArticleText, @"\[\[[W]yn Jones]]");
			if (m.Success) ArticleText = ArticleText.Replace(@"(?<=[[Wyn Jones)\|.*?(?=]])", "[[Wyn Jones (rugby union)]]");
			else ArticleText += "";

		return ArticleText;
	}
usernamekiran 29-Aug-20 23:40pm View
   
I also tried this code (with "Regex.Replace" as well, still the same error:
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
	{
		Skip = false;
		Summary = "test";

			Match m = Regex.Match(ArticleText, @"\[\[[W]yn Jones]]");
			if (m.Success) ArticleText = ArticleText.Replace("(?<=\[\[Wyn Jones)\|.*?(?=\]\])", "[[Wyn Jones (rugby union)]]", RegexOptions.IgnoreCase);												
			else ArticleText += "";

		return ArticleText;
	}
usernamekiran 29-Aug-20 22:50pm View
   
Hi. With your code, I created this:
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
	{
		Skip = false;
		Summary = "test";
			Match m = Regex.Match(ArticleText, @"\[\[[W]yn Jones]]");
			if (m.Success) ArticleText = Regex.Replace("(?<=\[\[Wyn Jones)\|.*?(?=\]\])", "[[Wyn Jones (rugby union)]]");
			else ArticleText += "";

		return ArticleText;
	}

But it is giving me "[CS1009] Unrecognized escape sequence" error, wherever we used \ to escape. I also tried:
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
	{
		Skip = false;
		Summary = "test";

			Match m = Regex.Match(ArticleText, @"\[\[[W]yn Jones]]");
			if (m.Success) ArticleText = ArticleText.Replace("(?<=\[\[Wyn Jones)\|.*?(?=\]\])", "[[Wyn Jones (rugby union)]]");
			else ArticleText += "";            
		return ArticleText;
	}

It gave the same error. Surprisingly, AWB regex page gives out the same method for escaping at: https://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Regular_expression

What am I doing wrong?