RegEx Format Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?anAybXNmdA==?=

    RegEx Format Help

    Prior to now, my RegEx expression was as follows:

    RegEx pattern = new Regex(@"[BCX][P057]\d{5} \d{4} \d{2}");

    That has worked, but now I have been asked to enable the ability for our
    expressions to include an underscore ('_') at each of the character
    positions. (This is an SQL Query, and the underscore acts as a wildcard for
    individual characters)

    Is there a nice way to modify my RegEx expression to include the underscore
    in a smart manner? (I'm not very good at creating RegEx expressions)
  • =?UTF-8?B?QXJuZSBWYWpow7hq?=

    #2
    Re: RegEx Format Help

    jp2msft wrote:
    Prior to now, my RegEx expression was as follows:
    >
    RegEx pattern = new Regex(@"[BCX][P057]\d{5} \d{4} \d{2}");
    >
    That has worked, but now I have been asked to enable the ability for our
    expressions to include an underscore ('_') at each of the character
    positions. (This is an SQL Query, and the underscore acts as a wildcard for
    individual characters)
    >
    Is there a nice way to modify my RegEx expression to include the underscore
    in a smart manner? (I'm not very good at creating RegEx expressions)
    RegEx pattern = new Regex(@"[BCX_][P057_]\d{5} \d{4} \d{2}");

    ?

    Or do you want underscore support for the digits as well ?

    Arne

    Comment

    • =?Utf-8?B?anAybXNmdA==?=

      #3
      Re: RegEx Format Help

      Hi Arne,

      Yes, the digits are the part I'm having the most trouble with.

      Do I have to list each digit individually?

      "Arne Vajhøj" wrote:
      jp2msft wrote:
      Prior to now, my RegEx expression was as follows:

      RegEx pattern = new Regex(@"[BCX][P057]\d{5} \d{4} \d{2}");

      That has worked, but now I have been asked to enable the ability for our
      expressions to include an underscore ('_') at each of the character
      positions. (This is an SQL Query, and the underscore acts as a wildcard for
      individual characters)

      Is there a nice way to modify my RegEx expression to include the underscore
      in a smart manner? (I'm not very good at creating RegEx expressions)
      >
      RegEx pattern = new Regex(@"[BCX_][P057_]\d{5} \d{4} \d{2}");
      >
      ?
      >
      Or do you want underscore support for the digits as well ?
      >
      Arne
      >

      Comment

      • =?UTF-8?B?QXJuZSBWYWpow7hq?=

        #4
        Re: RegEx Format Help

        jp2msft wrote:
        "Arne Vajhøj" wrote:
        >jp2msft wrote:
        >>Prior to now, my RegEx expression was as follows:
        >>>
        >>RegEx pattern = new Regex(@"[BCX][P057]\d{5} \d{4} \d{2}");
        >>>
        >>That has worked, but now I have been asked to enable the ability for our
        >>expressions to include an underscore ('_') at each of the character
        >>positions. (This is an SQL Query, and the underscore acts as a wildcard for
        >>individual characters)
        >>>
        >>Is there a nice way to modify my RegEx expression to include the underscore
        >>in a smart manner? (I'm not very good at creating RegEx expressions)
        >RegEx pattern = new Regex(@"[BCX_][P057_]\d{5} \d{4} \d{2}");
        >>
        >?
        >>
        >Or do you want underscore support for the digits as well ?
        Yes, the digits are the part I'm having the most trouble with.
        >
        Do I have to list each digit individually?
        Just replace \d with [0-9_].

        Arne

        Comment

        • =?Utf-8?B?anAybXNmdA==?=

          #5
          Re: RegEx Format Help

          Works beautifully! Thank you, Sir!

          "Arne Vajhøj" wrote:
          Just replace \d with [0-9_].
          >
          Arne
          >

          Comment

          Working...