Question: ```
MailMessage msg = new MailMessage();
msg.Body = "";
msg.To.Add(...);
msg.To.Add(...);

SmtpClient smtp = new SmtpClient();
smtp.Send(msg);

```

This sends the same subject and body to multiple address. 
However I want unique mail to be send to each.

Any solution other than looping through?

Answer: 
If I understand the requirements correctly, You can use something like this. To round values and get the interpretation, it is recommended to use a `DecimalFormatter`. Avoid using JDK internal libraries for this.

```
public static void main( String[] args )
{
    DecimalFormat df = new DecimalFormat( "0.00" );

    //0.52 -> IntPMF[(0;0.48)(1;0.52)]
    String stoEx = "0.5 * x + 0.32222* y";
    Pattern p = Pattern.compile( "(\\d+\\.\\d+)" );
    Matcher m = p.matcher( stoEx );
    String result = "";
    StringJoiner stringJoiner = new StringJoiner( "+" );
    String[] splitString = stoEx.split( "\\+" );
    for( String subString: splitString )
    {
        if( m.find() )
        {
            String fracPart = m.group( 1 ).split( "\\." )[1];
            String fracOne = df.format( 1 - ( Integer.parseInt( fracPart ) / Math.pow( 10.0, fracPart.length() ) ) );
            String fracTwo = df.format( ( Integer.parseInt( fracPart ) / Math.pow( 10.0, fracPart.length() ) ) );
            String resultEx = "IntPMF[(" + 0 + ";" + fracOne + ")(" + 1 + ";" + fracTwo + ")]";
            result = subString.replaceFirst( m.group( 1 ), resultEx );
            stringJoiner.add( result );
        }
    }
    System.out.println( stringJoiner.toString() );
}

```
I've ommited computation part as you're interested in clear text replacements:

```
    final private static Pattern doublePattern = Pattern.compile("\\d+\\.\\d+");
    final private static String outputTemplate = "IntPMF[(0;%1$s)(1;%2$s)]";

    public static void main(String[] args) {
        String text = "0.5 * x + 0.32222* y";

        StringBuilder sb = new StringBuilder();

        int pos = 0;
        Matcher matcher = doublePattern.matcher(text);
        while(matcher.find()) {
            Double d = Double.parseDouble(matcher.group());
            String s1 = "s1"; // compute first parameter here
            String s2 = "s2"; // compute second parameter here

            // add part before matching
            sb.append(text.substring(pos, matcher.start()));
            pos = matcher.end();
            // add template
            sb.append(String.format(outputTemplate, s1, s2));
        }
        // add leftovers
        sb.append(text.substring(pos));

        System.out.println(sb);
    }

```