Easy question (I think)

kservice

Newcomer
Joined
Jan 13, 2004
Messages
24
Hi all,

What would be the pattern for finding the last comma in a line of text?

Ex: Brown, Brown, Brown, Brown, Brown, Brown

Thanks a bunch! ;)
 
You don't need a regex for this. Just use:

Dim s As String="Brown, Brown, Brown, Brown, Brown, Brown"
Dim pos as integer=s.LastIndexOf(",")

:)
 
I was looking for a regular expression because I have to replace the last comma with the word "and".

I wanted to use a regular expression because I can find and replace with one line of code instead of several.

Thanks for your help. :)
 
Well that was the point of the brackets i.e. you replace

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

with

" and $2"

How does your's work Ingis? I can't say I follow it...
 
Back
Top