Search/Replace with GREP wildcards

2,334 views
Skip to first unread message

1611mac

unread,
May 18, 2016, 1:31:08 PM5/18/16
to BBEdit Talk
Is it possible to "Replace" wildcard strings?

For example, given this "FIND" string entered in Find and Replace:  ="#.*"  

How would I "REPLACE" the wildcard text found with the same text set in all caps?


Example:
="#foo"  becomes ="#FOO"




Sam Hathaway

unread,
May 18, 2016, 1:37:54 PM5/18/16
to BBEdit Talk
Hi,

Find: ="#(.*)"
Replace: ="#\U\1\E"

Hope this helps.
-sam
> --
> This is the BBEdit Talk public discussion group. If you have a
> feature request or would like to report a problem, please email
> "sup...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
>
> ---
> You received this message because you are subscribed to the Google
> Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bbedit+un...@googlegroups.com.
> To post to this group, send email to bbe...@googlegroups.com.

1611mac

unread,
May 18, 2016, 2:54:33 PM5/18/16
to BBEdit Talk
Awesome!  I learned a lot just from that one simple little blurb!  Thank you very much!  Perfect!  Over 4k lines changed in a couple seconds!

Christopher Stone

unread,
May 18, 2016, 4:11:33 PM5/18/16
to BBEdit-Talk
On May 18, 2016, at 13:08, 1611mac <161...@gmail.com> wrote:
> Awesome! I learned a lot just from that one simple little blurb!
______________________________________________________________________

Hey There,

If you work with text a lot and don't know at least a smattering of RegEx you're missing out.

Here's my handy reference for BBEdit.

BBEdit-TextWrangler_RegEx_Cheat_Sheet:

https://gist.github.com/ccstone/5385334

--
Best Regards,
Chris

Steve Piercy

unread,
May 18, 2016, 4:21:04 PM5/18/16
to bbe...@googlegroups.com
On 5/18/16 at 3:11 PM, listm...@suddenlink.net (Christopher
Stone) pronounced:

>On May 18, 2016, at 13:08, 1611mac <161...@gmail.com> wrote:
>>Awesome! I learned a lot just from that one simple little blurb!
>______________________________________________________________________

>BBEdit-TextWrangler_RegEx_Cheat_Sheet:
>
>https://gist.github.com/ccstone/5385334

Another option is the BBEdit reference "Searching with Grep",
which I bookmarked and view in a web browser because the Apple
Help viewer has a terrible UI.
file:///Applications/BBEdit.app/Contents/Resources/BBEdit%20Help/index_grep.htm

I also use this tool a lot. The live preview is quick, and the
community around it shares common regexes.
https://regex101.com/

--steve

------------------------
Steve Piercy, Soquel, CA

Luis Speciale

unread,
May 18, 2016, 5:49:25 PM5/18/16
to bbe...@googlegroups.com

Christopher Stone

unread,
May 18, 2016, 6:20:32 PM5/18/16
to BBEdit-Talk
On May 18, 2016, at 15:20, Steve Piercy <steve.pi...@gmail.com> wrote:
Another option is the BBEdit reference "Searching with Grep", which I bookmarked and view in a web browser because the Apple Help viewer has a terrible UI.
______________________________________________________________________

Hey Steve,

Good idea, although not everyone will place BBEdit in the /Applications folder.

Here's how to script it and let the OSX find the app for you.

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/05/18 17:08
# dMod: 2016/05/18 17:13 
# Appl: BBEdit & Safari
# Task: Open BBEdit's “Searching with Grep” Chapter in Safari
# Tags: @Applescript, @Script, @, BBEdit, @Safari, @Open, @Help
-------------------------------------------------------------------------------------------

set grepHelp to "/Contents/Resources/BBEdit%20Help/index_grep.htm"
set shCMD to "mdfind -onlyin /Applications/ 'kMDItemCFBundleIdentifier == \"com.barebones.bbedit\"'"
set bbeditApp to do shell script shCMD
set grepHelpPath to "file://" & bbeditApp & grepHelp

tell application "Safari"
  activate
  make new document with properties {URL:grepHelpPath}
  # My preferred window location and size – change to suit.
  set bounds of front window to {228, 23, 1542, 1196}
end tell

-------------------------------------------------------------------------------------------

Charles Nichols

unread,
Dec 23, 2019, 11:46:00 AM12/23/19
to BBEdit Talk
Is it possible to find and delete every instance of  

<a href="../programs/20141201-IlPreteDISIS.pdf" target="_blank" class="internal">Program (PDF)</a>

in a file, using wildcards instead of "20141201-IlPreteDISIS", which is a name of a PDF, that will be different for each instance, but always in the pattern "Date-Name"?

On Wednesday, May 18, 2016 at 6:20:32 PM UTC-4, Christopher Stone wrote:

Massimo Rainato

unread,
Dec 23, 2019, 12:58:34 PM12/23/19
to bbe...@googlegroups.com
In a 3 step yes.
1) change first part fix with @@@@
2) change lastpart with €€€€
3) change @@@@(.*)€€€€ with none 

--
This is the BBEdit Talk public discussion group. If you have a
feature request or need technical support, please email

"sup...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <https://twitter.com/bbedit>

---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.

Sam Hathaway

unread,
Dec 23, 2019, 1:06:16 PM12/23/19
to BBEdit Talk

On 23 Dec 2019, at 11:44, Charles Nichols wrote:

Is it possible to find and delete every instance of

<a href="../programs/20141201-IlPreteDISIS.pdf" target="_blank"
class="internal">Program (PDF)</a>

in a file, using wildcards instead of "20141201-IlPreteDISIS", which is a
name of a PDF, that will be different for each instance, but always in the
pattern "Date-Name"?

Yes, using this Grep pattern:

<a href="\.\./programs/\s+-\w+\.pdf" target="_blank" class="internal">Program \(PDF\)</a>

Assumptions:

  • the “Date” will always consist of one or more digits (\d+).
  • the “Name” will always consist of one or more word characters (\w+).
  • the link text will always be “Program (PDF)”.

Hope this helps.
-sam

Charles Nichols

unread,
Dec 23, 2019, 2:03:09 PM12/23/19
to bbe...@googlegroups.com
Thank you very much.  That worked perfectly.

Charles Nichols


Reply all
Reply to author
Forward
0 new messages