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. C#
  4. Regex.....Problem...........

Regex.....Problem...........

Scheduled Pinned Locked Moved C#
regexhelp
2 Posts 2 Posters 0 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.
  • S Offline
    S Offline
    Siddharth Rastogi
    wrote on last edited by
    #1

    string sPattern = @"[^\p{Cc}\\r\\n\\a\\e\\b\\t][\S]*[\w\p{Po}\s-`\p{Sm}]*[^\p{Cc}\\r\\n\\a\\e\\b\\t]"; try { if (Regex.IsMatch(txtText.Text, sPattern, RegexOptions.Multiline | RegexOptions.IgnoreCase)) { objMatch = Regex.Match(txtText.Text, sPattern, RegexOptions.ECMAScript | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase); if (objMatch.Success) lblDone.Text = objMatch.Value; }//end (if (Regex.IsMatch...) }//end(try) finally { sPattern = null; }//end (finally) input string is :-- \r\nloadplayer "playername=test_1"\r\n output string should be :-- loadplayer "playername=test_1" want to neglect all newline,tabs.. etc from the input string. Now its doing fine, but also removing "r,n,a,e,b,t" from the starting of the input string. Means, if the input string is:-- roadplayer "playername=test_1"\r\n output becomes:-- oadplayer "playername=test_1" it should be:-- roadplayer "playername=test_1" so, tell me what i should do for better working. Thxx... Enjoy!!

    M 1 Reply Last reply
    0
    • S Siddharth Rastogi

      string sPattern = @"[^\p{Cc}\\r\\n\\a\\e\\b\\t][\S]*[\w\p{Po}\s-`\p{Sm}]*[^\p{Cc}\\r\\n\\a\\e\\b\\t]"; try { if (Regex.IsMatch(txtText.Text, sPattern, RegexOptions.Multiline | RegexOptions.IgnoreCase)) { objMatch = Regex.Match(txtText.Text, sPattern, RegexOptions.ECMAScript | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase); if (objMatch.Success) lblDone.Text = objMatch.Value; }//end (if (Regex.IsMatch...) }//end(try) finally { sPattern = null; }//end (finally) input string is :-- \r\nloadplayer "playername=test_1"\r\n output string should be :-- loadplayer "playername=test_1" want to neglect all newline,tabs.. etc from the input string. Now its doing fine, but also removing "r,n,a,e,b,t" from the starting of the input string. Means, if the input string is:-- roadplayer "playername=test_1"\r\n output becomes:-- oadplayer "playername=test_1" it should be:-- roadplayer "playername=test_1" so, tell me what i should do for better working. Thxx... Enjoy!!

      M Offline
      M Offline
      Matthew Butler 0
      wrote on last edited by
      #2

      The 'escape characters' are all in the format '\x'. \n is new line... etc. '\\' in a string represents a '\', a single '\' will look like an escape character. So you need to use: \n \r etc instead of \\n \\r. I've never use Regex before but I assume this is right. Hope it helps.

      Matthew Butler

      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