Link to home
Create AccountLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

ActionScript 3: REGEX to replace multiple spaces with  

Using ActionScript 3, I want to replace multiple spaces with  .
var ExtraSpaces:RegExp = /^\s+|\s+$/g;
var string:String = "Hello,     spaces are around the     world";
string = string.replace(ExtraSpaces, " ");

// I want this:
// Hello,     spaces are around the     world

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of deepanjandas
deepanjandas
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of hankknight

ASKER

I only want this to apply if there is more than one space in a row.   Does your code do this for all spaces or only when two or more spaces are next to each other?


for all spaces available in the text :)

Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com 
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account