On Aug 18, 2011, at 03:23, Mark wrote: > Does anybody know if there's a way to enter today's date via search and > replace? I have files with strings like this > <imported>2009-02-12</imported> and I'm processing them with a text factory
______________________________________________________________________ Hey Mark, I don't generally fool with Text Factories, so I can't help with the specifics. Here's how I'd do it with Applescript. There are 3 different methods for assembling your date, and then the regex. Oh, I'm accounting for the possibility that you have dates formatted in to ways: yyyy/m/d yyyy/mm/dd -- Best Regards, Chris -------------------------------------------------------------------- set cDate to current date -------------------------------------------------------------------- set dateString to short date string of cDate # Dependent upon system date settings -------------------------------------------------------------------- set dd to text -2 thru -1 of ("0" & (day of cDate as integer)) set mm to text -2 thru -1 of ("0" & (month of cDate as integer)) set yyyy to year of cDate as text -------------------------------------------------------------------- set dateString to yyyy & "/" & mm & "/" & dd -------------------------------------------------------------------- set dateString to do shell script "date \"+%Y-%m-%d\"" -------------------------------------------------------------------- tell application "BBEdit" try tell text of front text window set resultNumber1 to replace ¬ "<imported>\\d{4}-\\d{1,2}-\\d{1,2}</imported>" using ¬ "<imported>" & dateString & "</imported>" options ¬ {search mode:grep, starting at top:true, case sensitive:false} end tell on error errMsg number errNum set sep to "==============================" set e to sep & return & "Error: " & errMsg & return & sep & return ¬ & "Error Number: " & errNum & return & sep beep display dialog e end try end tell -- You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at <http://groups.google.com/group/bbedit?hl=en> If you have a feature request or would like to report a problem, please email "supp...@barebones.com" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>