The easiest thing might be to just add a new paragraph after the current one.
var pgf = foundText.beg.obj;
var newPgf = doc.NewSeriesPgf (pgf);
I've not time to check this, but if a search string has a backslash, that backslash might be consumed by the compiler or interpreter. Try a double backslash, e.g. "\\PStart of a line".
Note also that there are new find properties and values for regular expressions. These don't appear in the FDK documentation:
#define FS_FindCustomizationFlags 15 /* IntT the following ored together */
#define FF_FIND_USE_REGEX ((IntT) 0x10)
#define FS_RegexFlavour 17 /*Enum one of the following*/
#define FR_USE_PERL 1 /*Use perl flavour*/
#define FR_USE_GREP 2 /*Use grep flavour*/
#define FR_USE_EGREP 3 /*Use egrep flavour*/
I find that the newline escape sequence (\n) inserts a carriage return. As in:
replaceString = "Some whole new paragraph.\n";
Note, however, that I don't know that this is the "correct" way to do it. Sometimes incorrect methods introduce weird, hidden characters into a doc. My suspicion, though, is that this technique is OK.