regex question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Smokey Grindle

    #1

    regex question

    I am writing a messaging app (email like) and want to check if a message has
    a RE: or FWD: already and if so put a RE[1]: or FWD[1]: type of prefix on it
    that increments automatically on each reply to one that has that message
    already in it... so the sequence would be like this

    Original Message
    RE: Original Message
    RE[1]: Original Message
    RE[2]: Original Message
    ...... and so on... is there any easy way to do this with a regex or anyone
    that has done this before that knows how to? thanks!


  • Jared Parsons

    #2
    Re: regex question

    Hello Smokey,
    [color=blue]
    > I am writing a messaging app (email like) and want to check if a
    > message has a RE: or FWD: already and if so put a RE[1]: or FWD[1]:
    > type of prefix on it that increments automatically on each reply to
    > one that has that message already in it... so the sequence would be
    > like this
    >
    > Original Message
    > RE: Original Message
    > RE[1]: Original Message
    > RE[2]: Original Message
    > ..... and so on... is there any easy way to do this with a regex or
    > anyone
    > that has done this before that knows how to? thanks![/color]

    Try the following regex

    "^RE(\[(?<value>\d+)\])?:.*"

    This will match all of the strings you specified. If the Match object contains
    a Group called "value", it will contain the number inside the []'s. Example

    Dim match As Match = Regex.Match(lin e, "^RE(\[(?<value>\d+)\])?:.*")
    If match.Success Then
    ' It's a RE: line
    if match.Groups.Co ntains("value") Then
    ' It has a []
    Dim value As Integer = CInt(match.Grou ps("value").Val ue)



    --
    Jared Parsons [MSFT]
    jaredpar@online .microsoft.com


    Comment

    • Smokey Grindle

      #3
      Re: regex question

      Thanks a lot!... I realy need to get regex's memorized so I can actually
      understand them better...

      "Jared Parsons" <jaredpar@onlin e.microsoft.com > wrote in message
      news:61f143b1a6 88c868baea630a3 3@msnews.micros oft.com...[color=blue]
      > Hello Smokey,
      >[color=green]
      >> I am writing a messaging app (email like) and want to check if a
      >> message has a RE: or FWD: already and if so put a RE[1]: or FWD[1]:
      >> type of prefix on it that increments automatically on each reply to
      >> one that has that message already in it... so the sequence would be
      >> like this
      >>
      >> Original Message
      >> RE: Original Message
      >> RE[1]: Original Message
      >> RE[2]: Original Message
      >> ..... and so on... is there any easy way to do this with a regex or
      >> anyone
      >> that has done this before that knows how to? thanks![/color]
      >
      > Try the following regex
      >
      > "^RE(\[(?<value>\d+)\])?:.*"
      >
      > This will match all of the strings you specified. If the Match object
      > contains a Group called "value", it will contain the number inside the
      > []'s. Example
      >
      > Dim match As Match = Regex.Match(lin e, "^RE(\[(?<value>\d+)\])?:.*")
      > If match.Success Then
      > ' It's a RE: line if match.Groups.Co ntains("value") Then
      > ' It has a [] Dim value As Integer = CInt(match.Grou ps("value").Val ue)
      >
      >
      > --
      > Jared Parsons [MSFT]
      > jaredpar@online .microsoft.com
      >
      >[/color]


      Comment

      • GhostInAK

        #4
        Re: regex question

        Hello Smokey,

        Try Expresso from http://www.ultrapico.com/

        -Boo
        [color=blue]
        > Thanks a lot!... I realy need to get regex's memorized so I can
        > actually understand them better...
        >
        > "Jared Parsons" <jaredpar@onlin e.microsoft.com > wrote in message
        > news:61f143b1a6 88c868baea630a3 3@msnews.micros oft.com...
        >[color=green]
        >> Hello Smokey,
        >>[color=darkred]
        >>> I am writing a messaging app (email like) and want to check if a
        >>> message has a RE: or FWD: already and if so put a RE[1]: or FWD[1]:
        >>> type of prefix on it that increments automatically on each reply to
        >>> one that has that message already in it... so the sequence would be
        >>> like this
        >>>
        >>> Original Message
        >>> RE: Original Message
        >>> RE[1]: Original Message
        >>> RE[2]: Original Message
        >>> ..... and so on... is there any easy way to do this with a regex or
        >>> anyone
        >>> that has done this before that knows how to? thanks![/color]
        >> Try the following regex
        >>
        >> "^RE(\[(?<value>\d+)\])?:.*"
        >>
        >> This will match all of the strings you specified. If the Match
        >> object contains a Group called "value", it will contain the number
        >> inside the []'s. Example
        >>
        >> Dim match As Match = Regex.Match(lin e, "^RE(\[(?<value>\d+)\])?:.*")
        >> If match.Success Then
        >> ' It's a RE: line if match.Groups.Co ntains("value") Then
        >> ' It has a [] Dim value As Integer =
        >> CInt(match.Grou ps("value").Val ue)
        >> --
        >> Jared Parsons [MSFT]
        >> jaredpar@online .microsoft.com[/color][/color]


        Comment

        • Smokey Grindle

          #5
          Re: regex question

          thanks!

          "GhostInAK" <ghostinak@gmai l.com> wrote in message
          news:be1391bfc5 da8c868d43ed7a4 a7@news.microso ft.com...[color=blue]
          > Hello Smokey,
          >
          > Try Expresso from http://www.ultrapico.com/
          >
          > -Boo
          >[color=green]
          >> Thanks a lot!... I realy need to get regex's memorized so I can
          >> actually understand them better...
          >>
          >> "Jared Parsons" <jaredpar@onlin e.microsoft.com > wrote in message
          >> news:61f143b1a6 88c868baea630a3 3@msnews.micros oft.com...
          >>[color=darkred]
          >>> Hello Smokey,
          >>>
          >>>> I am writing a messaging app (email like) and want to check if a
          >>>> message has a RE: or FWD: already and if so put a RE[1]: or FWD[1]:
          >>>> type of prefix on it that increments automatically on each reply to
          >>>> one that has that message already in it... so the sequence would be
          >>>> like this
          >>>>
          >>>> Original Message
          >>>> RE: Original Message
          >>>> RE[1]: Original Message
          >>>> RE[2]: Original Message
          >>>> ..... and so on... is there any easy way to do this with a regex or
          >>>> anyone
          >>>> that has done this before that knows how to? thanks!
          >>> Try the following regex
          >>>
          >>> "^RE(\[(?<value>\d+)\])?:.*"
          >>>
          >>> This will match all of the strings you specified. If the Match
          >>> object contains a Group called "value", it will contain the number
          >>> inside the []'s. Example
          >>>
          >>> Dim match As Match = Regex.Match(lin e, "^RE(\[(?<value>\d+)\])?:.*")
          >>> If match.Success Then
          >>> ' It's a RE: line if match.Groups.Co ntains("value") Then
          >>> ' It has a [] Dim value As Integer =
          >>> CInt(match.Grou ps("value").Val ue)
          >>> --
          >>> Jared Parsons [MSFT]
          >>> jaredpar@online .microsoft.com[/color][/color]
          >
          >[/color]


          Comment

          Working...