Nov 30, 2005 #1 K 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!
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!
Nov 30, 2005 #2 M mark007 Well-known member Joined Jan 22, 2005 Messages 182 Location York, UK 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(",")
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(",")
Nov 30, 2005 #3 K kservice Member Joined Jan 13, 2004 Messages 24 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.
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.
Nov 30, 2005 #4 M mark007 Well-known member Joined Jan 22, 2005 Messages 182 Location York, UK Ah ok, how about: "(,)([^,]*)$"
Nov 30, 2005 #5 IngisKahn Well-known member Joined Jan 9, 2005 Messages 432 Location Philadelphia, PA That will give you ", Brown" Id go with: ,(?!(?:.*,))
Dec 1, 2005 #6 M mark007 Well-known member Joined Jan 22, 2005 Messages 182 Location York, UK 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...
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...
Dec 1, 2005 #7 K kservice Member Joined Jan 13, 2004 Messages 24 Thanks both of you. From what you gave me I got it to work exactly like I needed. Thanks again.
Dec 1, 2005 #8 IngisKahn Well-known member Joined Jan 9, 2005 Messages 432 Location Philadelphia, PA mark007 said: How does yours work Ingis? I cant say I follow it... Click to expand... , 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 ))
mark007 said: How does yours work Ingis? I cant say I follow it... Click to expand... , 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 ))