Loading ...
Sorry, an error occurred while loading the content.

23582Testing for Well Formed Numeric Field

Expand Messages
  • Art Kocsis
    Jan 2, 2013
      I don't have much hair left to pull so maybe you guys can save
      my scalp and suggest a way to make this search pattern work in
      a clip.

      I am trying to verify a selection to be a well formed numeric
      field. By that I mean, the selection may have leading white space,
      possibly a plus or minus sign (possibly followed by horizontal
      white space), followed by one or more decimal digits with no
      embedded or trailing white space. The total width of the selection
      is fixed and known and may range from one to a large number. The
      selection may be preceded or followed by any text. The preceding
      code guarantees the selection to contain at least one non-white-
      space character.

      For example these would all be well formed, valid fields:
      <any text> + 123<any txt>
      <any text> +123<any txt>
      <any text> - 123<any txt>
      <any text>+ 3<any txt>
      <any text>+ 356456 [next line is at EOF]
      <any text>+ 3

      And these would all be ill-formed, invalid fields:

      <any text> -+ 123<any txt> [multiple operators]
      <any text> 2+23<any txt> [embedded operator]
      <any text> - 1 23<any txt> [embedded white space]
      <any text>+ aa 3<any txt> [non-digit character]
      <any text> 2 <any txt> [trailing white space] [next line is at EOF]
      <any text>a+ 3

      The RegEx pattern, "^\s*[\+-]?\s*\d*?\K[\D]+?", seemed to work OK
      in the Toolbar dialog. Although the toolbar Find does not respect
      selection boundaries for selections less than 24 characters, the
      matches found for valid fields were outside the selection field
      and could be testable by their column number.

      However, in a clip (target fields are preselected),

      ^!Find "^\s*[\+-]?\s*\d*?\K[\D]+?" HRS

      yields entirely different results and consistently matches valid
      operators and white space within the selection. It seems that the
      clip command is respecting the selection.

      Upon further investigation, I found that pressing the F3 key to
      invoke the search (instead of clicking the Find next button),
      yields the same results as the clip. Another inconsistency of

      Any suggestions on how to make this pattern work in a clip?

      Darn - I just realized I forgot all about decimal points. Best
      leave them for later as this clip was just for integers.
    • Show all 4 messages in this topic