- 论坛徽章:
- 0
|
现在有个例子想做如下需求,source是要格式化的文本,行数不定。
1>第一个格式化需求是,把带有select、from、where关键字的行单独列出
2>第二个格式化需求是,把带有select、from、where关键字的行头和行尾个加上一个注释,关键字行的注释和其他行不一样,
2.1>在select行行头加111,行尾是222.
2.2>select和from之间的普通行行头'aaa'行尾'bbb'
2.3>在from行头注释是333,行尾444,
2.4>并且还要在from这行前加一整行注释'there will be the from clause'
2.5>from和where之间的普通行行头ccc行尾ddd
2.6>where行头555,行尾666
2.7>where后面到文件末尾,行头eee 行尾fff
这里涉及到的知识点大概是
1> 如何划分这几个部分 select == from from==where where==$
2> 怎么单独处理这些关键字行,并且能整合到一起,是使用数组还是行读呢?
3> .....
Source:
select a.user_name,
a.table_name,
b.db_name
from abc_table a, test_table b
where a.job_name=b.job_name;
Target1:
select
a.user_name,
a.table_name,
b.db_name
from
abc_table a,
test_table b
where
a.job_name=b.job_name;
Target2:
'111' select '222'
'aaa' a.user_name, 'bbb'
'aaa' a.table_name, 'bbb'
'aaa' b.db_name 'bbb'
'there will be the from clause'
'333' from '444'
'ccc' abc_table a, 'ddd'
'ccc' test_table b 'ddd'
'555' where '666'
'eee' a.job_name=b.job_name; 'fff' |
|