removing anything inside <> brackets in Numbers

I have a numbers DB I exported from PHPMyAdmin and need to remove anything inside <> brackets throughout - is there a wildcard I can use to remove them (eg <*>)?

iMac Line (2012 and Later)

Posted on Oct 9, 2020 5:40 AM

Reply
5 replies

Oct 9, 2020 7:38 AM in response to SGIII

Does this do what you want?



-- place the markup you want to remove between the curly brackets
-- each must be enclosed by ""
-- any. embedded " must be 'escaped' with \ as shown

set markupToRemove to {"<p><span style=\"color: #888888;\">", "</span></p>"}

set replaceWith to {}
repeat (length of markupToRemove) times
	set end of replaceWith to ""
end repeat

tell front document of application "Numbers"
	tell active sheet
		tell (first table whose class of selection range is range)
			repeat with c in cells of (get selection range)
				set origVal to value of c
				set value of c to my substitute(markupToRemove, replaceWith, origVal)
			end repeat
		end tell
	end tell
end tell

on substitute(s, r, t)
	set s to s as list
	set r to r as list
	set t to t as text
	repeat with i from 1 to count s
		set text item delimiters to item i of s
		set t to text items of t
		set text item delimiters to item i of r
		set t to t as text
	end repeat
	return t
end substitute


  1. Copy-paste script into Script Editor (in Applications > Utilities)
  2. In a duplicate of your document select the (non-blank). cells you want to clean of markup
  3. Click the run <triangle> button.


If "nothing happens" make sure Script Editor is listed and checked at System Preferences > Security & Privacy > Privacy > Accessibility.


If you have other markup you need to remove include it in the markupToRemove AppleScript list as noted in the script.


SG

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

removing anything inside <> brackets in Numbers

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.