Skip to content
View in the app

A better way to browse. Learn more.

Opusmodus

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Title followed by number in brackets in xml files

Featured Replies

if I enter a string as title in defscore and export the score as xml file, the title is always followed by a number in square brackets: Title [12]. How can I get rid of this addition?Acoustic-Scale.xml

  • Author

Thanks. Good to know. I'll delete them in my notation software.

  • Author

With this code, I eliminate the brackets directly in the xml file:

;; Clean up titles with number-brackets generated by Opusmodus

(defun clean-xml-bracket-numbers (filepath)

"Remove any ' [123]' pattern from an XML file after export."

(let* ((text (read-file-string filepath))

;; Use a simpler string replacement if regex is problematic

(clean (remove-bracket-numbers text)))

(with-open-file (out filepath

:direction :output

:if-exists :supersede

:if-does-not-exist :create

:external-format :utf-8)

(write-string clean out))

filepath))

(defun remove-bracket-numbers (string)

"Remove patterns like ' [123]' from string using string functions."

(let ((pos 0)

(result ""))

(loop while (< pos (length string)) do

(let ((bracket-pos (position #\[ string :start pos)))

(if bracket-pos

(progn

(setf result (concatenate 'string result (subseq string pos bracket-pos)))

;; Check if this is a number in brackets

(let ((close-pos (position #\] string :start (1+ bracket-pos))))

(if (and close-pos

(every #'digit-char-p

(subseq string (1+ bracket-pos) close-pos)))

(setf pos (1+ close-pos)) ; Skip the bracket number

(progn

(setf result (concatenate 'string result "["))

(setf pos (1+ bracket-pos))))))

(progn

(setf result (concatenate 'string result (subseq string pos)))

(setf pos (length string))))))

result))

  • Author

Here is a new version of my "number cleaner-functions" for xml exports. The old version doesn't remove the space before the bracket and added a nil at the end of the file. This new one works better:

(defun clean-xml-bracket-numbers (filepath)

"Remove any ' [123]' pattern from an XML file after export."

(let* ((text (read-file-string filepath))

;; Remove any trailing null characters first

(cleaned-text (string-right-trim (list #\null #\nul) text))

;; Remove bracket numbers with preceding space

(clean (remove-bracket-numbers cleaned-text)))

(with-open-file (out filepath

:direction :output

:if-exists :supersede

:if-does-not-exist :create

:external-format :utf-8)

(write-string clean out))

filepath))

(defun remove-bracket-numbers (string)

"Remove patterns like ' [123]' from string using string functions.

Also removes the space before the bracket."

(let ((pos 0)

(result (make-string (length string) :element-type 'character))

(result-pos 0))

(loop while (< pos (length string)) do

(let ((space-pos (position #\space string :start pos)))

(if space-pos

(progn

;; Copy up to the space

(loop for i from pos below space-pos do

(setf (char result result-pos) (char string i))

(incf result-pos))

;; Check if next character is '['

(if (and (< (1+ space-pos) (length string))

(char= (char string (1+ space-pos)) #\[))

(let ((close-pos (position #\] string :start (+ space-pos 2))))

(if (and close-pos

(every #'digit-char-p

(subseq string (+ space-pos 2) close-pos)))

;; Found pattern " [123]" - skip the space and the brackets with numbers

(setf pos (1+ close-pos))

;; Not our pattern, keep the space

(progn

(setf (char result result-pos) #\space)

(incf result-pos)

(setf pos (1+ space-pos)))))

;; No bracket after space, keep the space

(progn

(setf (char result result-pos) #\space)

(incf result-pos)

(setf pos (1+ space-pos)))))

;; No more spaces, copy remaining text

(progn

(loop for i from pos below (length string) do

(setf (char result result-pos) (char string i))

(incf result-pos))

(setf pos (length string))))))

;; Return only the filled portion of the result string

(subseq result 0 result-pos)))

  • Author

This is exactly what's done in my posted function. Thanks. "Easy" just for coders!

Create an account or sign in to comment


Copyright © 2014-2026 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.