• 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 Stories
  • Fun
  • Culture
  • Learn
  • Tech
  • Search
You are here: Home / Technology / 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
Facebook0Tweet0Pin0LinkedIn0
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

Related Posts:

  • OurTunes - Hack iTunes And Make It Function Like Napster (2004)
    OurTunes - Hack iTunes And Make It Function Like…
  • Apogee Duet Review - Advanced Audio Interface Adapter For Macintosh
    Apogee Duet Review - Advanced Audio Interface…
  • DJs And Students Find Uses For The iPod Beyond Just A Music Player
    DJs And Students Find Uses For The iPod Beyond Just…

Facebook0Tweet0Pin0LinkedIn0
Category: Software, DIY & How To Tag: Bare Bones Software, BBEdit, code, GREP, Ken Thompson, Mac OS X, Microsoft, Microsoft Word, Unix
Previous Post: « Social Media KPIs and Data 12 Critical Social Media KPIs That You $hould Be Tracking
Next Post: Fletch Quotes: 30 Of The Funniest Quotes From The Movie Fletch Fletch Quotes »

Sidebar

Trending Now

  • 20 Famous People Who Are Members Of The Sleepless Elite20 Famous People Who Are Members Of The Sleepless Elite
  • 5 Easy Elevator Hacks That Will Help Give You An Express Ride5 Easy Elevator Hacks That Will Help Give You An Express Ride
  • How To Easily Create A PayPal Shipping Label Without InvoiceHow To Easily Create A PayPal Shipping Label Without Invoice
  • Controversial Nimbus 2000 Vibrating Harry Potter Broomstick Has Parents In An UproarControversial Nimbus 2000 Vibrating Harry Potter Broomstick Has Parents In An Uproar
  • 7 Pictures Of Naked People Captured By Google's Cameras7 Pictures Of Naked People Captured By Google’s Cameras
  • The 30 Best Caddyshack Quotes That'll Make You LaughThe 30 Best Caddyshack Quotes That’ll Make You Laugh
  • 30 Best Spinal Tap Quotes That All Rock Fans Should Know30 Best Spinal Tap Quotes That All Rock Fans Should Know
  • 22 Inspirational Dr. Seuss Quotes To Help Motivate Your Life22 Inspirational Dr. Seuss Quotes To Help Motivate Your Life
  • 30 Of The Best Goonies Quotes30 Of The Best Goonies Quotes
  • 50+ Famous Happy Birthday Quotes From Notable Personalities50+ Famous Happy Birthday Quotes From Notable Personalities

Categories

The Creation: Baby Yoda

10 Stunning Pieces Of Star Wars Art: A Mashup Of Famous Paintings And Characters From Star Wars

Big Lebowski Quotes

The 15 Best Big Lebowski Quotes That Really Tie The Room Together

Pour yourself the perfect White Russian cocktail because the Dude abides. We’ve got some of the best Big Lebowski quotes for your enjoyment.



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

Big Lebowski Quotes

The 15 Best Big Lebowski Quotes That Really Tie The Room Together

Two NYC Pigeons Commit Premeditated Homicide By Pushing Another Pigeon Into An Oncoming Subway Train

Two NYC Pigeons Commit Premeditated Homicide By Pushing Another Pigeon Into An Oncoming Subway Train

Follow

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

Copyright © 2021 MethodShop · All Rights Reserved · Powered by BizBudding Inc.

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie settingsACCEPT
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled

Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.

Non-necessary

Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.

SAVE & ACCEPT