Author Topic: Edit tip - inserting text, and "*"  (Read 1788 times)

0 Members and 1 Guest are viewing this topic.

kenbrody

  • Administrator
  • Posts: 82
    • View Profile
Edit tip - inserting text, and "*"
« on: December 11, 2006, 03:24:14 PM »
If you have a need to write an edit which will insert text into the field, and have a wildcard-accept ("*"), the edit can fail even with seemingly-valid data.

For example, given the edit:

    expand   { !"#1"!<Harry> | !"#2"!<Ron> | !"#3"!<Hermione> | * }

(that is, expand "#1" to "Harry", "#2" to "Ron", and "#3" to "Hermione"), any input which expands the data will fail, regardless of the field length.

The reason for this is simple -- the final * accepts all trailing spaces, thereby causing the output data to be too long for the field.

In order to fix this, you need to tell the edit to delete any trailing spaces in the field:

    expand   { {!" "!}@ | !"#1"!<Harry> | !"#2"!<Ron> | !"#3"!<Hermione> | * }

Note the @ after the "delete any amount of spaces".  This means "match end-of-field".  Without this, it would mean "delete any amount of spaces, regardless of where they occur" -- in other words, "remove all spaces".  With the @, only spaces followed by end-of-field -- ie: "trailing spaces" -- will be deleted.
Kenneth Brody
aka "Mr. filePro"  :-)