split on string

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I want to split not on a character, but on a string. Is this possible?
What Im trying to do is enforce that there is a decimal following a number, the input files Im getting sometimes have a decimal, like 4.1, but sometimes, when its 4.0, its set as 4
So Id like to split on "_IndexRate" and grab the next character, to make sure it comes out as 4.0. I was alternatively thinking of parsing through the file using indexOf and substring. This is someone elses code, when the decimals are all there,
the program works, fine, but when theyre not, its not, so I thought the path of least resistance is to ensure the input is consistent. WDYT?
<pre><?xml version="1.0"?>
<PRICE_YIELD_ANALYSIS _SeriesNumber="3898" _CollateralStatus="Assumed" _Source="FHLMC" _DealerName="CITIGROUP GLOBAL MARKETS, INC.
<OCS_GROUP _Number="1" _SettlementDate="2011-07-29" _FirstPaymentDate="2011-08-15
<PRICE_YIELD_UNIT>
<CLASS _Id="TG" _AssumedPrice="97.75" _Cap="6.500000" _InitialCouponRate="6.500000000" _InitialAccrualPeriod="28" _Floor="0.000000" _Multiplier="1" _OriginalUpb="5028144.000000" _Spread="266.500000000"/>
<SCENARIO _PrepaymentSpeedValue="100" _PrepaymentSpeedType="PSA" _IndexRate="4" _IndexName="LIBOR_1MO"/>
<PRICE_YIELD_DETAIL _YieldPct="6.77022"/>
</PRICE_YIELD_UNIT>
<PRICE_YIELD_UNIT>
<CLASS _Id="TG" _AssumedPrice="97.75" _Cap="6.500000" _InitialCouponRate="6.500000000" _InitialAccrualPeriod="28" _Floor="0.000000" _Multiplier="1" _OriginalUpb="5028144.000000" _Spread="266.500000000"/>
<SCENARIO _PrepaymentSpeedValue="100" _PrepaymentSpeedType="PSA" _IndexRate="4.05" _IndexName="LIBOR_1MO"/>
<PRICE_YIELD_DETAIL _YieldPct="3.41506"/>
</PRICE_YIELD_UNIT>
<PRICE_YIELD_UNIT>
<CLASS _Id="TG" _AssumedPrice="97.75" _Cap="6.500000" _InitialCouponRate="6.500000000" _InitialAccrualPeriod="28" _Floor="0.000000" _Multiplier="1" _OriginalUpb="5028144.000000" _Spread="266.500000000"/>
<SCENARIO _PrepaymentSpeedValue="100" _PrepaymentSpeedType="PSA" _IndexRate="4.1" _IndexName="LIBOR_1MO"/>
<PRICE_YIELD_DETAIL _YieldPct="0.10695"/>
</PRICE_YIELD_UNIT>
<PRICE_YIELD_UNIT>[/code]


View the full article
 
Back
Top