regex question

  • Thread starter Thread starter Smokey Grindle
  • Start date Start date
S

Smokey Grindle

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!
 
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(line, "^RE(\[(?<value>\d+)\])?:.*")
If match.Success Then
' It's a RE: line
if match.Groups.Contains("value") Then
' It has a []
Dim value As Integer = CInt(match.Groups("value").Value)
 
Thanks a lot!... I realy need to get regex's memorized so I can actually
understand them better...

Jared Parsons said:
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(line, "^RE(\[(?<value>\d+)\])?:.*")
If match.Success Then
' It's a RE: line if match.Groups.Contains("value") Then
' It has a [] Dim value As Integer = CInt(match.Groups("value").Value)
 
Hello Smokey,

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

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

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(line, "^RE(\[(?<value>\d+)\])?:.*")
If match.Success Then
' It's a RE: line if match.Groups.Contains("value") Then
' It has a [] Dim value As Integer =
CInt(match.Groups("value").Value)
 
thanks!

GhostInAK said:
Hello Smokey,

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

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

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(line, "^RE(\[(?<value>\d+)\])?:.*")
If match.Success Then
' It's a RE: line if match.Groups.Contains("value") Then
' It has a [] Dim value As Integer =
CInt(match.Groups("value").Value)
 
Back
Top