Poida
6 years agoOccasional Contributor
Find and Replace with Regular Expression in Script using Javascript
Hi, i'm having trouble with doing a find and replace using regex on a string in a script using Javascript.
The idea is to get rid of all multiple consecutive white space characters in the strin...
- 6 years ago
Thanks tristaanogre, that tipped me off. Needed the gi switch at the end to work and it was using the javascript re syntax not the native testcomplete one. Below is the working code.
function UseRegex() { var regex = /\s+/gi; var Instr = " Words with too much space |"; var ResStr = Instr.replace(regex," "); Log.Message(ResStr); }