• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
  • About
  • Contact
  • Subscribe
  • Advertise
methodshop

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

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

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.

February 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

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, Mac OS X, Microsoft, Microsoft Word, Unix
Previous Post:Social Media KPIs and Data12 Critical Social Media KPIs That You $hould Be Tracking
Next Post:Fletch Quotes: 30 Of The Funniest Quotes From The Movie FletchFletch Quotes

Reader Interactions

Comments

  1. Jeffrey12TA7

    September 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

    September 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

    January 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

  • Job Automation Using ChatGPT Could Make These Jobs Obsolete - Is Your Job On This List?Job Automation Using ChatGPT Could Make These Jobs Obsolete – Is Your Job On…
  • The Surprising Story Behind The NBC ChimesThe Surprising Story Behind The NBC Chimes
  • 7 Pictures Of Naked People Captured By Google's Cameras7 Pictures Of Naked People Captured By Google’s Cameras
  • How To Change The Default LG TV Home Screen To Live TVHow To Change The Default LG TV Home Screen To Live TV
  • 5 Funny Resurrection Jokes To Share On Easter Sunday5 Funny Resurrection Jokes To Share On Easter Sunday
  • 20 Famous People Who Are Members Of The Sleepless Elite20 Famous People Who Are Members Of The Sleepless Elite
  • Top 200 Nielsen DMA Rankings (2023) – Full ListTop 200 Nielsen DMA Rankings (2023) – Full List
  • Is Your Hatch Restore Already Registered? Here's How To Fix It And Unregister A Hatch Restore.Is Your Hatch Restore Already Registered? Here’s How To Fix It And…
  • The Best Caddyshack Quotes: 30 Famous Caddyshack Quotes That'll Make You LaughThe Best Caddyshack Quotes: 30 Famous Caddyshack Quotes That’ll Make You Laugh
  • 30 Dirty Irish Pick Up Lines That Will Probably Get You Slapped30 Dirty Irish Pick Up Lines That Will Probably Get You Slapped

Categories

Ask Alexa St. Patrick's Day - Funny St. Patrick's Day Jokes & Irish Jokes

10 Fun Things To Ask Alexa On St. Patrick’s Day

Amazon’s Alexa can be a fun and helpful part of your St. Patrick’s Day celebrations and activities. Here are some fun Irish and St. Patrick’s Day related things to #AskAlexa.

How To Visually Identify AI-Generated Text

How To Manually Identify AI-Generated Text Without Using A ChatGPT Detector

Wondering if what you’ve read is bot or human-generated? AI text detectors can help, but can be time-consuming. Here’s how humans can train to identify AI-generated text.

Recent Posts

  • How To Manually Identify AI-Generated Text Without Using A ChatGPT Detector
  • 10 Clever Tech Gifts That People Actually Want
  • 10 Fun Things To Ask Alexa On St. Patrick’s Day
  • 30 Dirty Irish Pick Up Lines That Will Probably Get You Slapped
  • Why Chuck E. Cheese Is Still Using Floppy Disks To Make Its Rodent Mascot Dance

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.

Latest

How To Visually Identify AI-Generated Text

How To Manually Identify AI-Generated Text Without Using A ChatGPT Detector

Clever Tech Gifts

10 Clever Tech Gifts That People Actually Want

Follow

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • Pinterest
MethodShop Animated Zoom Icon
  • About
  • Submit
  • Disclaimer
  • Privacy Policy
  • Contact
  • Subscribe
  • Store

Copyright © 2023 MethodShop · All Rights Reserved