Hi I have a file where i want to remove a char before a specific pattern.
exp:
CREATE TABLE
(
A,
B,
C, ----comma needs to be removed
)AS SELECT
A,
B,
C, ----comma needs to be removed
FROM TABLE.
So i want to delete the comma(,) after the C both ways.Pattern can be look for ")AS SELECT" and "FROM" .So before this pattern i want to delete a single char which is comma.
my output should:
CREATE TABLE
(
A,
B,
C -----removed comma
)AS SELECT
A,
B,
C -----removed comma
FROM TABLE.
The column "C" is not always constant.So thats why i said based on the pattern before the one character which is comma(,) need to be removed.MAy be sometime more columns come..
/*in below example comma needs to remove after C*/
CREATE TABLE
(
A,
B,
C, ----comma needs to be removed
)AS SELECT
A,
B,
C, ----comma needs to be removed
FROM TABLE
/*in below example comma needs to remove after D*/
CREATE TABLE
(
A,
B,
C,
D, ----comma needs to be removed
)AS SELECT
A,
B,
C,
D, ----comma needs to be removed
FROM TABLE.
Expected O/P
/*comma removed from C in both place*/
CREATE TABLE
(
A,
B,
C -----comma removed
)AS SELECT
A,
B,
C -----comma removed
FROM TABLE;
/*comma replaced from D */
CREATE TABLE
(
A,
B,
C,
D ----comma removed
)AS SELECT
A,
B,
C,
D ----comma removed
FROM TABLE3.
you can use pattern because the pattern is constant...like "FROM" and ")AS SELECT". Need to remove the comma before these two patterns.