• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
  • About
  • Contact
  • Subscribe
  • Advertise
method logo sxs 280x96 wht

methodshop

tech news, reviews & how to's

  • Trending
  • Latest
  • Tech
    • Apps
    • Internet
    • Software
    • Security
    • Games
    • Advertising
  • Life
    • Entertainment
    • TV & Film
    • Music
    • Health & Science
    • Family
    • Social Media
    • Food
    • Style
  • Learn
    • Tutorials
    • Reviews
    • News
      • Business
      • Crime
      • Politics
  • Fun
    • Featured
    • Humor
    • Holiday
    • Random Articles

Home : Software : How To Use The BBEdit GREP Advanced Find And Replace Function

coding
coding

How To Use The BBEdit GREP Advanced Find And Replace Function

This article will help you get started with BBEdit GREP advanced find and replace functions and point you in the right direction in case you have more advanced questions.

Feb 24, 2018 by jayfrankwilson
FacebookTweetPinLinkedIn
Table of Contents[Hide][Show]
  • Who Created GREP?
  • What Does GREP Mean?
  • A Simple BBEdit GREP Find & Replace
  • Some Great GREP Examples+−
    • Removing Whitespace
    • Mult-Find
  • Advanced BBEdit GREP
Reading Time: 2 minutes

Anyone who does any coding or text editing in Mac OS X is probably familiar with BBEdit. Bare Bones Software, the company behind BBEdit (and it’s now defunct, sibling TextWrangler) wanted to create a simple but very powerful barebones text editing app. BTW I’ve opened 200MB+ text files with BBEdit without a problem. Since its debut on April 1992, BBEdit has been a staple of power Macintosh users everywhere. But one of the least understood features of BBEdit is its GREP advanced find and replace function.

This article will help you get started with BBEdit GREP advanced find and replace functions and point you in the right direction in case you have more advanced questions.

Who Created GREP?

It was created by legendary programmer Ken Thompson in 1974. Thompson also designed the Unix operating system, the UTF-8 character encoding for the world wide web, as well as several operating systems and programming languages.

What Does GREP Mean?

GREP stands for “Global regular expression print”. GREP allows you to quickly run complex find and replace commands that remove or leave characters.

A Simple BBEdit GREP Find & Replace

The “Save as Web Page” feature in Microsoft Word creates a lot of junk code. It’s ridiculous. Word will create 580+ lines of code before it gets to your first paragraph tag. GREP is the perfect tool to clean up Word’s mess.

The wildcard character combination (.*) will replace anything in its spot. Let’s say for example you have an HTML file with multiple font sizes and you want to make them all the same. Something like this:

  • <span style='font:5.0pt "Times New Roman"'>
  • <span style='font:6.0pt "Times New Roman"'>

You could run a single GREP that replaces all different font sizes all at once with one size, 7.0pt.

  • Search: <span style='(.*)pt "Times New Roman"'>
  • Replace: <span style='7.0pt "Times New Roman"'>

Some Great GREP Examples

The useful things that you can do with GREP are endless. Here are a few examples.

Removing Whitespace

Another annoying issue for most programmers is white space. This GREP command will remove all whitespace from the beginning of lines.





Search: ^[ \t]+
Replace:

Mult-Find

Need to search text files for mentions of specific words or phrases? This example searches US President Abraham Lincoln’s famous Gettysburg Address for the words nation, liberty and equality.

egrep 'nation|liberty|equality'

Advanced BBEdit GREP

Bbedit Grep Advanced Find And Replace Function

You can find several great BBedit GREP cheatsheets online with advanced search and replace examples.






  • BBEdit Grep Tutorial
  • Grep Cheatsheet

Related Articles:

  • How To Easily Enable GZIP Compression For Your Website
  • How to Force HTTPS By Modifying Your .htaccess File
  • When Was The Last Time You Updated Your WordPress Ping List?
  • Jimmy Kimmel Demonstrates How Easy It Is To Social Engineer Passwords


FacebookTweetPinLinkedIn
Category: Software, DIY & Tutorials, Featured Tag: BBEdit, code, GREP, Ken Thompson, macOS, Microsoft, Microsoft Word, Unix
Previous Post:social media data network12 Critical Social Media KPIs That You $hould Be Tracking
Next Post:Fletch Quotes: 30 Of The Funniest Quotes From The Movie Fletchfletch feature

Reader Interactions

Comments

  1. Jeffrey12TA7

    Sep 2, 2020 at 7:15 AM

    I’ve done this before but forget the exact steps. I think you can target a folder of text files or apply your search and replace to all open docs in BBEdit.

  2. Gregory Ledger

    Sep 1, 2020 at 3:27 PM

    How can I do multiple find and replaces on multiple documents. Most instructions show how to do one find and replace on multiple documents at a time in BBEdit. I need to find “phrase 1” and replace it with “phrase A”; find “phrase 2” and replace it with “phrase B”, and so on.

  3. DRocStgSpec

    Jan 23, 2020 at 9:41 PM

    worked like a charm!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar

Popular Posts

google naked

7 Pictures Of Naked People Captured By Google’s Cameras

lg tv disable home screen scaled

How To Change The Default LG TV Home Screen To Live TV

hatch restore sleep

Is Your Hatch Restore Already Registered? Here’s How To Fix It And Unregister A Hatch Restore.

rooftop woman

10 Naked Sunbathers Busted By Google Earth

couple kissing

Dating Acronyms: The Ultimate List Of Useful Dating Abbreviations

usb data blockers

The 6 Best USB Data Blockers To Prevent Hackers From Juice Jacking Your Files

Angry Irish Woman

30 Dirty Irish Pick Up Lines That Will Probably Get You Slapped

harrypotter sex

Controversial Nimbus 2000 Vibrating Harry Potter Broomstick Has Parents In An Uproar

A mom laughing at a smartphone and tablet

250+ Funny Dirty Mom Jokes That Will Make Everyone Laugh (Even Mom)! (NSFW)

Caddyshack Quotes

35 Famous Caddyshack Quotes That’ll Make You Laugh

Jump to comments

About

MethodShop’s mission is to entertain, inform, and sometimes gross you out. MethodShop has affiliate relationships, so we may get a small share of the revenue from your purchases. Items are sold by the retailer, not by us. All prices are subject to change.

Follow

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • Pinterest

Trending Posts

google naked

7 Pictures Of Naked People Captured By Google’s Cameras

lg tv disable home screen scaled

How To Change The Default LG TV Home Screen To Live TV

hatch restore sleep

Is Your Hatch Restore Already Registered? Here’s How To Fix It And Unregister A Hatch Restore.

Latest Posts

Image showing how used coffee grounds can make concrete stronger.

From Stronger Concrete To Reducing Waste – How Used Coffee Grounds Could Revolutionize The Concrete Industry

nasa moon trash

The Moon Has A Trash Problem Already – What Was Left On The Moon And Why

jupiter planet

30 Fascinating Facts About Jupiter

MethodShop Animated Zoom Icon
  • About
  • Submit
  • Disclaimer
  • Privacy Policy
  • Contact
  • Subscribe
  • Store

Copyright © 2023 MethodShop · All Rights Reserved.