find and replace
Michael Havens
bmike1 at gmail.com
Tue Feb 21 09:58:21 MST 2012
you are so helpful! Thanks for walking me through the command.
On Tue, Feb 21, 2012 at 7:32 AM, Sam Kreimeyer <skreimey at gmail.com> wrote:
> Here's a pdf of a quick guide to regular expressions
> http://www.addedbytes.com/download/regular-expressions-cheat-sheet-v1/pdf/
>
> Basically, it's a format for defining search patterns that supports
> special meanings for certain characters. For instance:
>
> a - finds any string like "a"
> a. - finds any string like "a" plus any other character except a new line
> (matches "aa", "ab", "ac", etc)
> a.* - finds any string like "a" plus zero or more characters except a new
> line (matches "aa", "abcdefghijk")
> Other special characters can further modify this behavior.
>
> So here's an explanation of the earlier command.
>
> 's/\.JPG$/.jpg/' *.JPG
>
> Basic search and replace format s/[string we search for]/[string to
> replace matches with]/
>
> "\.JPG$" - Because "." is special, we escape it with "\" to keep the regex
> from interpreting it, so the "." will be treated literally. "JPG" is what
> we're looking for. Placing a "$" at the end of the string tells the regex
> to match the string only at the end of the strings you're searching. This
> means that you will match "example.JPG" but not "JPG.example".
>
> ".jpg" - This is our replacement string. This is what goes in the place of
> every match we find.
>
> "*.JPG" - while this isn't part of the regex, "*" is a wildcard (can be
> substituted for any number of characters).
>
> Hope that helps!
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
--
:-)~MIKE~(-:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.PLUG.phoenix.az.us/pipermail/plug-discuss/attachments/20120221/b1d2d03b/attachment.html>
More information about the PLUG-discuss
mailing list