Pattern Match - substitute a string after the match 
Author Message
 Pattern Match - substitute a string after the match

Hi,

I am trying to automate a table creation process... As an example, I
have a huge file called tables.txt. I want to match the table
"ACCOUNTS" and then substitute the INITIAL 131072 and NEXT 131072 to
INITIAL 1M and NEXT 1M. This has to happen just in the "ACCOUNTS"
block.
Each block in the file starts with CREATE and ends with a slash /.

Does anyone have an example of how can I accomplish this? Any help is
appreciated.

tables.txt sample ->

CREATE TABLE "ACCOUNTING_ROLE"
(       "ROLE_CODE" VARCHAR2(15),
"ROLE_DESC" VARCHAR2(30),
"ROLE_TYPE" VARCHAR2(2)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "TEST"
/
CREATE TABLE "ACCOUNTS"
(       "ACCOUNT_ID" VARCHAR2(8),
"MAINT_FLAG" VARCHAR2(1),
"STATUS" VARCHAR2(1),
...
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "TEST"
/
...
....
.....

Thanks.



Wed, 09 Nov 2005 00:25:49 GMT  
 Pattern Match - substitute a string after the match

Quote:
> I am trying to automate a table creation process... As an example, I
> have a huge file called tables.txt. I want to match the table
> "ACCOUNTS" and then substitute the INITIAL 131072 and NEXT 131072 to
> INITIAL 1M and NEXT 1M. This has to happen just in the "ACCOUNTS"
> block.
> Each block in the file starts with CREATE and ends with a slash /.

> Does anyone have an example of how can I accomplish this? Any help
> is appreciated.

Look at the CPAN Parse::RecDescent module.  What you describe is
possible with regular expressions, but Parse::RecDescent will probably
serve you better in the long run.

Ted



Wed, 09 Nov 2005 01:52:12 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Repeat string matching/substituting ?

2. Pattern bug matching whitespace in multi-line match?

3. combine two pattern matches to one match?

4. Pattern matching, grabing everything right of the match

5. pattern matching with non-existence of a string

6. pattern matching with a string variable?

7. pattern matching with string variable?

8. Help on pattern matching, string size

9. pattern matching in multi-line strings fails under perl4.034

10. pattern match for 'string:

11. pattern matching; see content file as one string

12. pattern matching starting at end of string

 

 
Powered by phpBB® Forum Software