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. Regex in DataAnnotations that can unmatch a input string containing not paired double quote "

Regex in DataAnnotations that can unmatch a input string containing not paired double quote "

Scheduled Pinned Locked Moved Regular Expressions
regexquestion
2 Posts 2 Posters 9 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
    stevecwlee
    wrote on last edited by
    #1

    Dear experts, I want to write a Regex in DataAnnotations that can unmatch a input string containing not paired double quote " ie. check if zero or a paired double quote allowed in a input string. pls kindly advise. thx matched case: abcde "abcde" abc"d"e unmatched case: "abc"de" "abcde abc"de abcde" MY EXISTING CODE FYR:

    ...

    using System.ComponentModel.DataAnnotations;
    using Microsoft.Web.DynamicData;

    ...

    namespace EDMModel
    {
    [MetadataType(typeof(DETAIL_MetaData)), ScaffoldTable(true)]
    public partial class DETAIL{}

    public class DETAIL\_MetaData
    {
        \[Required, RegularExpression(@"\[^~\`!@#%&()={}|:;'<>,./+?\*^$\]\*", ErrorMessage = "Unsupported Character detected"), StringLength(20), Display(Order = 21)\]
        public object NAME1 { get; set; }
    

    ...

    ....

    C 1 Reply Last reply
    0
    • S stevecwlee

      Dear experts, I want to write a Regex in DataAnnotations that can unmatch a input string containing not paired double quote " ie. check if zero or a paired double quote allowed in a input string. pls kindly advise. thx matched case: abcde "abcde" abc"d"e unmatched case: "abc"de" "abcde abc"de abcde" MY EXISTING CODE FYR:

      ...

      using System.ComponentModel.DataAnnotations;
      using Microsoft.Web.DynamicData;

      ...

      namespace EDMModel
      {
      [MetadataType(typeof(DETAIL_MetaData)), ScaffoldTable(true)]
      public partial class DETAIL{}

      public class DETAIL\_MetaData
      {
          \[Required, RegularExpression(@"\[^~\`!@#%&()={}|:;'<>,./+?\*^$\]\*", ErrorMessage = "Unsupported Character detected"), StringLength(20), Display(Order = 21)\]
          public object NAME1 { get; set; }
      

      ...

      ....

      C Offline
      C Offline
      Captain Ketchup
      wrote on last edited by
      #2

      Not exactly sure how it is in DataAnnotations, but the regexp would be:

      ^[^"]*("[^"]*")*[^"]*$

      If you have further character limitations, you could put them in instead of just [^"]

      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