I have the following statement, "VARCHAR2 (a,2,c)", and the outputs I want are "a" , "2" and "c".
There're two problems. 1) How can I ignore the "VARCHAR2 (" and ")" by using the pattern? 2) Can the extracted "a", "2", "c" in the same group?
I can use subString & split to process it but I'm looking for idea by using pattern to do the same result. Thanks.
Joined: Jan 17, 2006
This code will extract all the characters as a group, but the commas are still there. You could use the String.split() method the extract the comma delimited Strings. The regex I came up with presupposes that there will always be at least one comma in the values, no commas outside of the values, but as many values as you want. If these assumptions don't match the actual problem, you'll have to adjust the regex accordingly. i.e. it will match: a,b,c a,b,c,d,e,f a, abc,def,ghi
but not: a abc
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Joined: Oct 27, 2004
Thanks for your reply.
Finally, I'd updated the pattern to the following to extract the (). And then I put the result into the matcher agin to get the result.