Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dears Monks, I want to process word through perl. How i can convert this vba macro to perl code (Microsoft VBScript Regular Expressions 5.5)

Replies are listed 'Best First'.
Re: VBA Macro
by setebos (Beadle) on Jan 17, 2009 at 15:21 UTC
    Perl regular expressions.
    In case that you want to process each word:
    $_ = "aaa bbb ccc"; @words = $_ =~ /(\w+)/g; # now the array "words" contains each word

    Update: you use ^[^\d+]+ - in Perl this is the same, but this regexp does not capture the words.
    Don't you mean (\w+)?
VBA Macro
by Anonymous Monk on Jan 17, 2009 at 14:42 UTC
    Dears Monks, I want to process word through perl. How i can convert this vba macro to perl code (Microsoft VBScript Regular Expressions 5.5) Dim varRegex As New RegExp Dim varMatch As Match Dim varMatchs As MatchCollection varRegex.Global = True varRegex.MultiLine = False varRegex.IgnoreCase = True varRegex.Pattern = "^[^\d+]+" st = Selection.Start If varRegex.test(docrange.Text) = True Then Set varMatchs = varRegex.Execute(docrange.Text) For Each varMatch In varMatchs ActiveDocument.Range(st, st + Len(varMatch.Value)).Select Selection.Style = "authors" Next End If Thanks.

      For the benefit of those of us who aren't expert in VBA (such as myself), could you translate this into English? What are you trying to do? What code have you written so far?

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

      You might like to look into using Win32::OLE. The docs have an example for Excel at least....


      Life is denied by lack of attention,
      whether it be to cleaning windows
      or trying to write a masterpiece...
      -- Nadia Boulanger