You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by David <ac...@yahoo.es> on 2006/05/17 11:59:26 UTC
How to use replaceregexp in multi-line context?
Dear members,
I would like to use the ant task replaceregexp in order to replace tablespace information on my sql scripts, my input file is some think like this:
CREATE INDEX IX_2_lra_country
ON @USER@.lra_country (be_code)
PCTFREE 10
INITRANS 2
MAXTRANS 255
TABLESPACE @TABLESPACE@
STORAGE (
INITIAL 524288
NEXT 524288
PCTINCREASE 0
MINEXTENTS 2
MAXEXTENTS 2147483645
)
;
I have found the following regular expresion will match what I want: ^[\s]*PCTFREE[\sa-zA-Z0-9@\(\)]*; so I want to replace all of this with the semi-colon symbol(";").
I am ussing the following invocation of replaceregexp:
<replaceregexp byline = "false" flags = "g"
file="${sql.dir}/oracle/lra-create-index-oracle.sql"
match="^[\s]*PCTFREE[\sa-zA-Z0-9@\(\)]*;"
replace=";">
</replaceregexp>
When I test this regular expression it works (but not under Ant). I get:
CREATE INDEX IX_2_lra_country
ON @USER@.lra_country (be_code);
It doesn't work with Ant because the regular expresion to find is spread in more than one line. If I put all in one line it matches the regular expression. I don't understand why because the \s includes the newline character too. I have tried to use the flag="sg" without success too and also to set byline="true".
Do you have any suggestion about that?,
Thanks in advance,
David
---------------------------------
Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2ยข/min with Yahoo! Messenger with Voice.