roger v
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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 <|:-)
You have stollen my wizzard hat <|:-)
ASKER
@Kaufmed:
Yes, the space before the j needs to be replaced and your regexp does that. thanks!
Yes, the space before the j needs to be replaced and your regexp does that. thanks!