Hi, I want to remove string starts with - can anyone help me?
This should get you started. Actionscript Code: var str:String = "- My String, test test.";var re:RegExp = /^-\s?/;// Search for a string that starts with "-" or "- "// String before changestrace(str);// If the string starts with - or -(space) then replace itif(re.test(str)){ while(re.exec(str) != null) { str = str.replace(re, ""); }}// String after changestrace(str);
var str:String = "- My String, test test.";var re:RegExp = /^-\s?/;// Search for a string that starts with "-" or "- "// String before changestrace(str);// If the string starts with - or -(space) then replace itif(re.test(str)){ while(re.exec(str) != null) { str = str.replace(re, ""); }}// String after changestrace(str);
Web developer - http://www.stevestalder.com To get the best, quickest help read this thread IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects!
thanks for the reply. /-.*/g works fine.
That pattern would match any string with a - in it, no matter what the position. Doesn't appear to work in my tests but if it works for you then problem solved.
Forum Rules