Stumped with simple regular expression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bryan Ax

    Stumped with simple regular expression

    My regular expression inadequacies are surfacing again...

    I'm trying to write a simple regex to match either the character S, or
    the character O, or the phrase SP (but not the phrase SO, or SP, or any
    other phrase).

    I've tried simply:

    [SO]|SP

    but that still seems to match the phrase 'SO'

    What I really need is something that says, the above, but don't allow
    'SO'.

    I feel so silly - I thought I was going to get this one done very
    quickly...

    Any help appreciated,

    Bryan

  • Bryan Ax

    #2
    Re: Stumped with simple regular expression

    Oops - error in above. It should read but not the phrase SO, or OP, or
    any
    other phrase). SP is OK.

    Comment

    • Jon Shemitz

      #3
      Re: Stumped with simple regular expression

      Bryan Ax wrote:
      [color=blue]
      > My regular expression inadequacies are surfacing again...
      >
      > I'm trying to write a simple regex to match either the character S, or
      > the character O, or the phrase SP (but not the phrase SO, or SP, or any
      > other phrase).[/color]

      sp|s|o

      --

      Midnight Beach is Jon Shemitz, a freelance programmer and author. Jon offers software consulting and contract services, and recently finished his 2nd book - .NET 2.0 for Delphi Programmers.

      Comment

      Working...