Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SUBSTITUTE() in Component Rule?

Status
Not open for further replies.

mladd

Programmer
Apr 12, 2006
46
Is it possible to use a SUBSTITUTE() in a component rule? I have not seen any limitations in the doc, but I can't seems to get it to work. Basically, I need to strip a <CR><LF> from an inbound address record and replace it with two spaces.

I have tried a few different variation of the following rule:
Code:
IF(FIND("<CR><LF>", $), SUBSTITUTE($,"<CR><LF>", "  "), NONE)
and just plain
Code:
SUBSTITUTE($,"<CR><LF>", "  ")

Does anyone have any ideas as to go about accomplishing this substitution?

Thanks in advance,
Mike
 
SUBSTITUTE($,"<<CR>><<LF>>", " ")

or

SUBSTITUTE($,"<<CR>>"+"<<LF>>", " ")

or

SUBSTITUTE($,"<NL>", "<SP><SP>")

I prefer using <SP> for spaces because it's visually clear that you have two spaces.
 
Thanks, eyetry! But the error I keep getting is " '$' expected " with any of these, and the rules I tried earlier, when I try to commit the rule.
 
Perhaps I should explain this further.

Every row is terminated with a <CR><LF>. The file we get from our vendor is created from a web page, and the addresses are a free form text box. I have been told that there is no way for them to validate for a line feed in the text box (which I don't buy at all, but they are the customer).

What happens is users sometimes hit enter while entering their address and when the file is transmitted to us, it thinks this is the end of line terminator, when in fact there is more data to validate.

Hence the reason for the substitution I am trying to perform here.
 
So, how is the text box defined in your tree?

item = text
size = 0-X

I assume $ = the element/item/text box.... not the value "$"

I'm not very XP'd with web stuff but could the CR LF be comming thru as another value? $CR$LF / BR or other?


By the way I wrote

SUBSTITUTE($,"<<CR>>"+"<<LF>>", " ")

should have been..

SUBSTITUTE($,"<<0D>>"+"<<0A>>", " ")

 
You can't do the substitute on input. It has to be on the output.
 
I just didn't get the reason to substitute the linebreak sequence with TWO spaces. Wouldn't just one be enough? If you just want to get rid of the <CR><LF> sequence, you could maybe define it as a floating component within the input, making the parser filter it out it during processing (similar to XML comments where <!-- ... --> is collected disctinctly).
 
Series Consumer, It's a fixed length file, so I need to accommodate for the two characters being stripped out.

I have even considered using a preprocessing map to take care of this, but since it only happens once every few weeks, I'm not going to add that overhead to this system (60 - 70 thousand rows regularly in the file).

I guess I can just live with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top