2. riešenie:

'*******************************************************************************

' PSPad - Update Last Update date and Save
'
' Description : Updates "// Last update: Mon D, YYYY" in active document
'               with current date and saves the document.
' Supports    : PHP, JavaScript and any text file containing the marker.
' Shortcut    : Ctrl+Shift+S
'*******************************************************************************


Option Explicit

Const module_name = "UpdateVersion"
Const module_ver  = "1.00"

'*******************************************************************************

' Main procedure
'*******************************************************************************

Sub UpdateVersion

Dim obj
Dim txt
Dim newDate
Dim re
Dim matches

Set obj = NewEditor()
obj.assignActiveEditor()

' Get whole document
txt = obj.Text

' Format current date as e.g. Aug 5, 2026
newDate = EnglishDate(Date)

' Regular expression for:
'
' // Last update: Jul 15, 2026
'
' The rest of the document is untouched.
Set re = New RegExp

re.Pattern = "(//[ ]*Last[ ]+update:[ ]*)[A-Za-z]{3}[ ]+[0-9]{1,2},[
]+[0-9]{4}"
re.Global = False
re.IgnoreCase = True

Set matches = re.Execute(txt)

If matches.Count = 0 Then
    MsgBox "Marker '// Last update:' was not found.", _
           vbExclamation, _
           "Update version"
    Exit Sub
End If

' Replace only the date
txt = re.Replace(txt, "$1" & newDate)

' Replace whole editor contents
obj.command("ecSelectAll")
obj.selText(txt)

' Save active document
runPSPadAction("aSave")

End Sub

'*******************************************************************************

' Return date using English abbreviated month names
'
' Example:
'   Aug 5, 2026
'*******************************************************************************

Function EnglishDate(d)

Dim months

months = Array( _
    "Jan", _
    "Feb", _
    "Mar", _
    "Apr", _
    "May", _
    "Jun", _
    "Jul", _
    "Aug", _
    "Sep", _
    "Oct", _
    "Nov", _
    "Dec" _
)

EnglishDate = months(Month(d) - 1) & _
              " " & _
              Day(d) & _
              ", " & _
              Year(d)

End Function

'*******************************************************************************

' PSPad initialization
'*******************************************************************************

Sub Init

addMenuItem _
    "Update Last update && Save", _
    "Version", _
    "UpdateVersion", _
    "Shift+Ctrl+S"

End Sub

-- 
<https://forum.pspad.com/read.php?1,79795,79798>
PSPad freeware editor https://www.pspad.com

Odpovedet emailem