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

Re: [Clip] Re: Selecting text and first column

Expand Messages
  • Robin Chapple
    Thanks Flo, That works a treat. I am sorry that I was unaware of the Regex issue, I ll be careful next time. Regards, Robin
    Message 1 of 16 , Apr 23, 2008
    • 0 Attachment
      Thanks Flo,

      That works a treat. I am sorry that I was unaware
      of the Regex issue, I'll be careful next time.

      Regards,

      Robin


      At 24/04/2008 05:12, Flo wrote:
      >@Robin
      >
      > > Thanks Flo, That retains only the first digit of the count.
      >
      >Sorry, in your sample data, I've seen only single-digit numbers
      >following the Country Code. Don certainly gave you the solution.
      >Please add a + in the Replace command too...
      >
      >^!SetListDelimiter ^%NL%
      >^!SetArray %Countries%=^$GetDocMatchAll("^[\w\x20]+?\x20\d+")$
      >^!Toolbar New Document
      >^!InsertText ^%Countries%
      >^!Replace "\w+\x20(\d+)$" >> "$1" AWRS
      >
      >@Don
      >
      > > As usual Flo, if we explain the regex used people will start
      > > to understand.
      >
      >You explained it — there's nothing to add. Maybe this...
      >
      >^ = Matches at beginning of line
      >
      >The space in the Character Class is needed because we've got compound
      >country names (like "Saudi Arabia").
      >
      >+? non-greedy is necessary, Don. Omit it, and you will see why.
      >
      >@Keith
      >
      > > If I may give at alternate solution...
      >
      >Perfect! Just for fun — here's another solution (taking as a basis
      >that the Country Codes always are in lower letters)...
      >
      >^!ClearVariable %Out%
      >^!Jump 1
      >^!Set %Lines%=^$GetTextLineCount$
      >^!SetListDelimiter ^%Space%
      >
      >:Loop
      >^!Find "(?-i)^([\w\x20]+)\x20[[:lower:]]+\x20(\d+)" R
      >^!Set %Sub%=^$GetReSubstrings$
      >^!Append %Out%=^%Sub%^%NL%
      >^!Dec %Lines%
      >^!If ^%Lines%=0 End
      >^!Goto Loop
      >
      >:End
      >^!Toolbar New Document
      >^!InsertText ^%Out%
      >
      >
      >Regards,
      >Flo
      >
      >
      >
      >------------------------------------
      >
      >Fookes Software: http://www.fookes.com/
      >NoteTab website: http://www.notetab.com/
      >NoteTab Discussion Lists: http://www.notetab.com/groups.php
      >
      >***
      >Yahoo! Groups Links
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.