OK, here's the setup. I have a string from which I want to extract two digits or two letters and may include the dollar sign, $. They are always surrounded by a colon and a comma. The following works for consistently pulling out the information (incomplete code, but you get the idea of what I'm using as a basis):
That setup pulls out the following:
:CO,
:15,
:15$,
I could use the MID function to pull off the leading colon and trailing comma, but that's no fun. What I'm wondering is, how would I set up sPattern to get this result:
CO
15
15$
That's the trick. I don't want the match to return the colon or comma. I'm going through the exercise of learning regular expressions and this has provided an interesting challenge for me that I'm unable to solve.
I could also somehow use the replace method I suppose, but that has proved even more difficult for me. What I've listed above has gotten me closest to the solution, but you are free to use whatever method you want, of course.
Onwards,
Q-
Code:
sPattern = "(:)([A-Z0-9]+)(\$?)(,)"
sString = "KEY(),600259:CO,1100083:15,1101412:15$,"
That setup pulls out the following:
:CO,
:15,
:15$,
I could use the MID function to pull off the leading colon and trailing comma, but that's no fun. What I'm wondering is, how would I set up sPattern to get this result:
CO
15
15$
That's the trick. I don't want the match to return the colon or comma. I'm going through the exercise of learning regular expressions and this has provided an interesting challenge for me that I'm unable to solve.
I could also somehow use the replace method I suppose, but that has proved even more difficult for me. What I've listed above has gotten me closest to the solution, but you are free to use whatever method you want, of course.
Onwards,
Q-