Link to home
Start Free TrialLog in
Avatar of roger v
roger vFlag for United States of America

asked on

Coldfusion regexp replace whitespace - question

Hi Experts,

I have a form that accepts input from a variety of databases. As a result, some of my datasources contain "dirty" data, as in having extra spaces in them. I need to do a rereplace of the whitespace, only if they exist, only in a specific portion of the string. My data looks like so:

zg - dt -track prep student body- junior high

Notice the white space after the 1st g (this is whitespace1), followed by the hyphen, then another white space after the hyphen and before the 1st d (this is whitespace2). And then another whitespace after the 1st t and before the next hyphen(this is whitespace3). I need to remove the whitespaces 1,2 & 3. I don't want to do anything to the whitespaces after that since they are needed there. How would I achieve this?
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
My is shorter <|:-)
Yours doesn't adhere to the requirement  : \
So I'm confused...  should the space between the hyphen and the "j" in "junior" be replaced or not? The selected solution will replace it.
Catch the thief!
You have stollen my wizzard hat <|:-)
Recommendation: Split points betwean http:#36471385 and http:#36471398
Avatar of roger v

ASKER

@Kaufmed:

Yes, the space before the j needs to be replaced and your regexp does that. thanks!