Easy question (I think)

kservice

Member
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 dont 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 yours work Ingis? I cant say I follow it...
 
mark007 said:
How does yours work Ingis? I cant say I follow it...

, the comma in question
(?! look ahead negative i.e. make sure this doesnt follow
(?: dont save this
.*, any number of charcters follwed by a comma
))
 
Back
Top