Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Regular Expressions
  4. How to skip a particular term in regex find and replace?

How to skip a particular term in regex find and replace?

Scheduled Pinned Locked Moved Regular Expressions
regexhelpquestionwpftutorial
2 Posts 2 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    usernamekiran
    wrote on last edited by
    #1

    Hello. I am an editor at english wikipedia. I am adding template of wikiproject banners on the talkpages of articles which come under the scope of wikiproject. Basically, I am adding

    {{WikiProject Espionage |importance=Mid |class=Start}}

    to the talkpages of the articles. For that I use a tool called as auto wiki browser (AWB). Wikipedia:AutoWikiBrowser - Wikipedia[^] Currently, I am using following module:

    public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
    {
    Regex header = new Regex(@"\{\{{WikiProject Espionage|{{WikiProject Espionage |{{WP Espionage|{{WikiProject Intelligence |", RegexOptions.IgnoreCase);
    Summary = "Added banner for [[WP:WikiProject Espionage|WikiProject Espionage]]";
    Skip = (header.Match(ArticleText).Success || !Namespace.IsTalk(ArticleTitle));
    if (!Skip)
    ArticleText = "{{WikiProject Espionage|class=|importance=|listas=}} \r" + ArticleText;
    return ArticleText;
    }

    In the module, "WP Espionage", and "WikiProject Intelligence" are shortcuts/redirects to WikiProject Espionage. The module tells AWB to add the template to the article, and skip if any of these templates are already present. But the problem is, there is another wikiproject by the "Wikiproject Intelligence Agency". So my module is skipping the pages if there is Wikiproject Intelligence Agency already present on the page. So my question is: is there a way to tell AWB to skip only if {{WikiProject Espionage, {{WP Espionage, and {{WikiProject Intelligence and to avoid the presence of {{Wikiproject Intelligence Agency ? Any help will be appreciated a lot. Regards, —usernamekiran.

    L 1 Reply Last reply
    0
    • U usernamekiran

      Hello. I am an editor at english wikipedia. I am adding template of wikiproject banners on the talkpages of articles which come under the scope of wikiproject. Basically, I am adding

      {{WikiProject Espionage |importance=Mid |class=Start}}

      to the talkpages of the articles. For that I use a tool called as auto wiki browser (AWB). Wikipedia:AutoWikiBrowser - Wikipedia[^] Currently, I am using following module:

      public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
      {
      Regex header = new Regex(@"\{\{{WikiProject Espionage|{{WikiProject Espionage |{{WP Espionage|{{WikiProject Intelligence |", RegexOptions.IgnoreCase);
      Summary = "Added banner for [[WP:WikiProject Espionage|WikiProject Espionage]]";
      Skip = (header.Match(ArticleText).Success || !Namespace.IsTalk(ArticleTitle));
      if (!Skip)
      ArticleText = "{{WikiProject Espionage|class=|importance=|listas=}} \r" + ArticleText;
      return ArticleText;
      }

      In the module, "WP Espionage", and "WikiProject Intelligence" are shortcuts/redirects to WikiProject Espionage. The module tells AWB to add the template to the article, and skip if any of these templates are already present. But the problem is, there is another wikiproject by the "Wikiproject Intelligence Agency". So my module is skipping the pages if there is Wikiproject Intelligence Agency already present on the page. So my question is: is there a way to tell AWB to skip only if {{WikiProject Espionage, {{WP Espionage, and {{WikiProject Intelligence and to avoid the presence of {{Wikiproject Intelligence Agency ? Any help will be appreciated a lot. Regards, —usernamekiran.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      if ( ArticleText.Contains( "Wikiproject Intelligence Agency" ) ){
      // To do.
      } else {
      // To do.
      }

      It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups