8

I am attempting to replace all "begin" and "dur" attribute values in my SVG code with one-tenth of (or ten times) their current values, in order to speed up/slow down animation for testing/debugging purposes.

e.g. replace dur="900s" with dur="90s"

My current regex: \(dur\|begin\)="\([0-9.]+\)s?"

and the replacement: \1="\,(/ \2 10)s"

I receive the error Error evaluating replacement expression: (wrong-type-argument number-or-marker-p #("900" 0 2 (rear-nonsticky display (fontified t face (nxml-attribute-value)) 2 3 (rear-nonsticky (display) fontified t face (nxml-attribute-value))))

Drew
  • 75,699
  • 9
  • 109
  • 225

1 Answers1

11

\2 in your replacement is a string, and it needs to be a number in order to perform the division.

You could convert it to a number using string-to-number, but there's in-built shorthand for treating a capture group as a number; so you just need to change \2 to \#2

phils
  • 48,657
  • 3
  • 76
  • 115
rpluim
  • 4,605
  • 8
  • 22