fred_gaou: -------------------------------------------------------------------------------- ... And the second part should delete the lines that doesn't contains [b]KBXXXXXX [/b] but it doesn't work. Here it is:
outputTxt = outputTxt.replace(/^[^K].*$/gm, ""); I tried with or without "g" or "m" modifier with no success. What it's driving me crazy, if I run the PSPAD replace dialog box with regexp ON and I use the same input as my script^[^K].*$, it works as it should be. Please find my script and examplehere (viz http://www.mediafire.com/download.php?4y2zinqwzoo ). -------------------------------------------------------------------------------- Hi, the main problem seems to be, that the replacement in pspad operates on lines, but js regexp on the whole string. ^...$ behaves quite a bit diffeent then. If you are only interested on the list of matches, there is no need to use replace, but e.g.: cite: -------------------------------------------------------------------------------- var inputTxt = actEd.text(); outputTxt = "" var reKBnr = new RegExp(/KB\d+/gi); while ((matchObj = reKBnr.exec(inputTxt)) != null){ outputTxt += (matchObj[0]+"\n") } actEd.text(outputTxt); -------------------------------------------------------------------------------- using replace, I only could come with a rather complicated: cite: -------------------------------------------------------------------------------- outputTxt = outputTxt.replace(/.*/gi, function(line){if ((m = /KB\d+/gi.exec(line)) != null){return m[0]+"\n";}else{return "";}} ); actEd.text(outputTxt); runPSPadAction("aRemoveBlankLines") -------------------------------------------------------------------------------- whole lines are searched with .* then the replacement function is used to check against KB\d+ hth, vbr -- <http://forum.pspad.com/read.php?2,51086,51088> PSPad freeware editor http://www.pspad.com
