I have a need to find the first occurrence of a string and am having some real problems in finding the right RegEx pattern to give me that.
I have (as an example) an SQL statement like
create view accounttransactions (acctid, dtposted, acyear, acmonth, trntype, payee, debit, credit, postto) as select trans.acctid, trans.dtposted, cast(strftime('%y', trans.dtposted) as integer), cast(strftime('%m', trans.dtposted) as integer), trans.trntype, trans.payee, case when trans.trnamt < 0 then cast(-trans.trnamt as double) else cast(0.0 as double) end, case when trans.trnamt > 0 then cast(trans.trnamt as double) else cast(0.0 as double) end, postacs.acname from trans inner join postacs on ( postacs.mkey = trans.secac );
I want to find the first occurrence of " as " but everything I have tried gets me all the " as ", like cast xx as etc.
For further information I actually want to replace this first ‘as’ with ‘as’ + endofline to get this:
create view accounttransactions (acctid, dtposted, acyear, acmonth, trntype, payee, debit, credit, postto) as
select trans.acctid, trans.dtposted, cast(strftime('%y', trans.dtposted) as integer), cast(strftime('%m', trans.dtposted) as integer), trans.trntype, trans.payee, case when trans.trnamt < 0 then cast(-trans.trnamt as double) else cast(0.0 as double) end, case when trans.trnamt > 0 then cast(trans.trnamt as double) else cast(0.0 as double) end, postacs.acname from trans inner join postacs on ( postacs.mkey = trans.secac );
Can someone help me, please?
Simon.