Loading ...
Sorry, an error occurred while loading the content.
 

Dollars and cents

Expand Messages
  • ehofferino
    Hi guys, I m looking to write a simple clip that searches through a block of text and replaces all instances of monetary notation that look like this: 44c with
    Message 1 of 7 , Apr 24, 2008
      Hi guys,

      I'm looking to write a simple clip that searches through a block of
      text and replaces all instances of monetary notation that look like this:

      44c

      with this

      $0.44.

      Here's what the block might look like before changes:

      ================

      KLA-Tencor-KLAC reports Q3 EPS 67c vs. consensus of 63c
      KLAC reports Q3 revenue of $602M vs. consensus of $586M.

      Cheesecake Factory-CAKE reports Q1 EPS of 21c vs. consensus of 21c
      Repots Q1 revenue of $393.8M vs. consensus of $396.3M.

      American Express-AXP reports Q1 EPS 84c vs. consensus of 81c
      Reports Q1 revenue $7.19B vs. consensus of $7.2B.

      Rambus-RMBS reports Q1 EPS (12c) vs. consensus of (6c)
      Reports Q1 revenue $39.7M vs. consensus of $40.23M.

      ================

      Here's what it should look like after changes:

      KLA-Tencor-KLAC reports Q3 EPS $0.67 vs. consensus of $0.63
      KLAC reports Q3 revenue of $602M vs. consensus of $586M.

      Cheesecake Factory-CAKE reports Q1 EPS of $0.21 vs. consensus of $0.21
      Repots Q1 revenue of $393.8M vs. consensus of $396.3M.

      American Express-AXP reports Q1 EPS $0.84 vs. consensus of $0.81
      Reports Q1 revenue $7.19B vs. consensus of $7.2B.

      Rambus-RMBS reports Q1 EPS ($0.12) vs. consensus of ($0.06)
      Reports Q1 revenue $39.7M vs. consensus of $40.23M.

      ===============

      Thanks
    • dracorat
      In a new clip, use: ^!REPLACE b( d)c b $0.0$1 AWRS ^!REPLACE b( d d)c b $0.$1 AWRS ^!REPLACE b( d+)( d d)c b $$1.$2 AWRS If you want
      Message 2 of 7 , Apr 24, 2008
        In a new clip, use:

        ^!REPLACE "\b(\d)c\b" >> "\$0.0$1" AWRS
        ^!REPLACE "\b(\d\d)c\b" >> "\$0.$1" AWRS
        ^!REPLACE "\b(\d+)(\d\d)c\b" >> "\$$1.$2" AWRS

        If you want me to explain the regular expressions, just say the word.
        --Keith

        --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@...> wrote:
        >
        > Hi guys,
        >
        > I'm looking to write a simple clip that searches through a block of
        > text and replaces all instances of monetary notation that look like
        this:
        >
        > 44c
        >
        > with this
        >
        > $0.44.
        >
        > Here's what the block might look like before changes:
        >
        > ================
        >
        > KLA-Tencor-KLAC reports Q3 EPS 67c vs. consensus of 63c
        > KLAC reports Q3 revenue of $602M vs. consensus of $586M.
        >
        > Cheesecake Factory-CAKE reports Q1 EPS of 21c vs. consensus of 21c
        > Repots Q1 revenue of $393.8M vs. consensus of $396.3M.
        >
        > American Express-AXP reports Q1 EPS 84c vs. consensus of 81c
        > Reports Q1 revenue $7.19B vs. consensus of $7.2B.
        >
        > Rambus-RMBS reports Q1 EPS (12c) vs. consensus of (6c)
        > Reports Q1 revenue $39.7M vs. consensus of $40.23M.
        >
        > ================
        >
        > Here's what it should look like after changes:
        >
        > KLA-Tencor-KLAC reports Q3 EPS $0.67 vs. consensus of $0.63
        > KLAC reports Q3 revenue of $602M vs. consensus of $586M.
        >
        > Cheesecake Factory-CAKE reports Q1 EPS of $0.21 vs. consensus of $0.21
        > Repots Q1 revenue of $393.8M vs. consensus of $396.3M.
        >
        > American Express-AXP reports Q1 EPS $0.84 vs. consensus of $0.81
        > Reports Q1 revenue $7.19B vs. consensus of $7.2B.
        >
        > Rambus-RMBS reports Q1 EPS ($0.12) vs. consensus of ($0.06)
        > Reports Q1 revenue $39.7M vs. consensus of $40.23M.
        >
        > ===============
        >
        > Thanks
        >
      • ehofferino
        Thanks Keith! I would love an explanation. Teach a man to fish...
        Message 3 of 7 , Apr 24, 2008
          Thanks Keith!

          I would love an explanation. Teach a man to fish...

          --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@...> wrote:
          >
          > In a new clip, use:
          >
          > ^!REPLACE "\b(\d)c\b" >> "\$0.0$1" AWRS
          > ^!REPLACE "\b(\d\d)c\b" >> "\$0.$1" AWRS
          > ^!REPLACE "\b(\d+)(\d\d)c\b" >> "\$$1.$2" AWRS
          >
          > If you want me to explain the regular expressions, just say the word.
          > --Keith
          >
          > --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@> wrote:
          > >
          > > Hi guys,
          > >
          > > I'm looking to write a simple clip that searches through a block of
          > > text and replaces all instances of monetary notation that look like
          > this:
          > >
          > > 44c
          > >
          > > with this
          > >
          > > $0.44.
          > >
          > > Here's what the block might look like before changes:
          > >
          > > ================
          > >
          > > KLA-Tencor-KLAC reports Q3 EPS 67c vs. consensus of 63c
          > > KLAC reports Q3 revenue of $602M vs. consensus of $586M.
          > >
          > > Cheesecake Factory-CAKE reports Q1 EPS of 21c vs. consensus of 21c
          > > Repots Q1 revenue of $393.8M vs. consensus of $396.3M.
          > >
          > > American Express-AXP reports Q1 EPS 84c vs. consensus of 81c
          > > Reports Q1 revenue $7.19B vs. consensus of $7.2B.
          > >
          > > Rambus-RMBS reports Q1 EPS (12c) vs. consensus of (6c)
          > > Reports Q1 revenue $39.7M vs. consensus of $40.23M.
          > >
          > > ================
          > >
          > > Here's what it should look like after changes:
          > >
          > > KLA-Tencor-KLAC reports Q3 EPS $0.67 vs. consensus of $0.63
          > > KLAC reports Q3 revenue of $602M vs. consensus of $586M.
          > >
          > > Cheesecake Factory-CAKE reports Q1 EPS of $0.21 vs. consensus of $0.21
          > > Repots Q1 revenue of $393.8M vs. consensus of $396.3M.
          > >
          > > American Express-AXP reports Q1 EPS $0.84 vs. consensus of $0.81
          > > Reports Q1 revenue $7.19B vs. consensus of $7.2B.
          > >
          > > Rambus-RMBS reports Q1 EPS ($0.12) vs. consensus of ($0.06)
          > > Reports Q1 revenue $39.7M vs. consensus of $40.23M.
          > >
          > > ===============
          > >
          > > Thanks
          > >
          >
        • dracorat
          You bet! In the find expression (what s left of ) b means boundary and matches the outer edges of any alpha numeric sequence. It is close (but not exactly
          Message 4 of 7 , Apr 25, 2008
            You bet!

            In the find expression (what's left of >>)

            \b means "boundary" and matches the outer edges of any alpha numeric
            sequence. It is close (but not exactly like) to the equation
            ^|$|[^1-0a-zA-Z_]

            (If your regular expression understanding is not yet up to
            understanding that, just remember, edges of words)

            So, by wrapping a regular expression in \b on both sides we force
            whole word matches (or in this case, whole number sequences.)

            So, starting the explanation again:
            \b - beginning of word
            ( - What's about to come, take note of
            \d - a single decimal character
            ) - stop taking note - from ( to ) we have our first "match" which in
            the output gets assigned to the variable $1
            c - this is a literal character because it doesn't have a backslash
            with it. So, we are telling it to find the letter "c". If we had the
            "c" in the parenthesis it would be a part of the $1 variable, which
            means it would be copied to the output and we don't want that. That's
            why it's outside the parenthesis.
            \b - end of word (so we don't match something like 2c2 for example. Or
            2cell or anything else that's not one digit and a letter "c".)

            Then, in the output (the area to the right of >>) we have to tell it
            what to do with what we found. Remember we saved the number as $1.

            \$ - because the dollar sign is usually special to regular
            expressions, we have to tell it that we really want a dollar sign. So
            it has a backslash before it which means "this really is a dollar sign
            that I want"
            0.0 - because we matched one digit numbers only, we are putting in the
            dollars as 0, a decimal point, and the dimes as zero.
            $1 - we captured one digit and it goes here. Remember, $1 is our variable.

            Thus, let's say the number was 6c

            We captured the 6. The "c" gets discarded because it was a part of the
            regular expression find but was outside of parenthesis.

            Then we inserted "$0.0" and then "6" which becomes "$0.06"

            Now, there's no way to tell regular expressions to formulate numbers
            with leading zeroes, which would be convenient, so we have to write
            regular expressions for each case where there would be a leading zero.

            So, the second expression is the same with two changes.

            First, it matches two digits, not one. (That's the \d\d sequence.)

            Since we are finding two digits, it doesn't make sense to count zero
            dimes and then insert a two digit number, so the output only specifies
            the whole dollar portion (which is 0).

            For the record, \d\d is functionally equivalent to \d{2} but when
            matching two to three characters I tend to just specify it like I did.
            I think it makes it more readable. But neither is more or less correct.

            Now, I could have ended there and fully answered your request, but I
            felt that in the event you had a three digit cents specification
            somewhere that you would want it changed (not likely, but possible) I
            finished with the last one too. What it does is find anything that is
            three or greater digits. It saves the last two digits to $2 and
            everything before that to $1.

            \b(\d+)(\d\d)c\b

            Word boundary, Any number of digits (save to $1), two digits (save to
            $2), the letter "c", word boundary.

            Then, in the output, since now we have a count of the number of
            dollars (in the sequence 1234c that would be 12 dollars) we don't
            specify 0 but rather what we discovered.

            And there you have it!

            --Keith

            (Admins, am I allowed to make a product recommendation that's a cheat
            sheet for regular expressions?)

            --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@...> wrote:
            >
            > Thanks Keith!
            >
            > I would love an explanation. Teach a man to fish...
            >
            > --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@> wrote:
            > >
            > > In a new clip, use:
            > >
            > > ^!REPLACE "\b(\d)c\b" >> "\$0.0$1" AWRS
            > > ^!REPLACE "\b(\d\d)c\b" >> "\$0.$1" AWRS
            > > ^!REPLACE "\b(\d+)(\d\d)c\b" >> "\$$1.$2" AWRS
            > >
            > > If you want me to explain the regular expressions, just say the word.
            > > --Keith
            > >
            > > --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@> wrote:
            > > >
            > > > Hi guys,
            > > >
            > > > I'm looking to write a simple clip that searches through a block of
            > > > text and replaces all instances of monetary notation that look like
            > > this:
            > > >
            > > > 44c
            > > >
            > > > with this
            > > >
            > > > $0.44.
            > > >
            > > > Here's what the block might look like before changes:
          • jane_sedgewick
            I m not sure about your boundary definition as ^|$|[^1-0a-zA-Z_] I don t understand the 1-0 part. Shouldn t it be 0-9? As in ^|$|[^0-9a-zA-Z_] ... variable.
            Message 5 of 7 , Apr 26, 2008
              I'm not sure about your boundary definition as
              ^|$|[^1-0a-zA-Z_]
              I don't understand the 1-0 part. Shouldn't it be 0-9?
              As in ^|$|[^0-9a-zA-Z_]

              --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@...> wrote:
              >
              > You bet!
              >
              > In the find expression (what's left of >>)
              >
              > \b means "boundary" and matches the outer edges of any alpha numeric
              > sequence. It is close (but not exactly like) to the equation
              > ^|$|[^1-0a-zA-Z_]
              >
              > (If your regular expression understanding is not yet up to
              > understanding that, just remember, edges of words)
              >
              > So, by wrapping a regular expression in \b on both sides we force
              > whole word matches (or in this case, whole number sequences.)
              >
              > So, starting the explanation again:
              > \b - beginning of word
              > ( - What's about to come, take note of
              > \d - a single decimal character
              > ) - stop taking note - from ( to ) we have our first "match" which in
              > the output gets assigned to the variable $1
              > c - this is a literal character because it doesn't have a backslash
              > with it. So, we are telling it to find the letter "c". If we had the
              > "c" in the parenthesis it would be a part of the $1 variable, which
              > means it would be copied to the output and we don't want that. That's
              > why it's outside the parenthesis.
              > \b - end of word (so we don't match something like 2c2 for example. Or
              > 2cell or anything else that's not one digit and a letter "c".)
              >
              > Then, in the output (the area to the right of >>) we have to tell it
              > what to do with what we found. Remember we saved the number as $1.
              >
              > \$ - because the dollar sign is usually special to regular
              > expressions, we have to tell it that we really want a dollar sign. So
              > it has a backslash before it which means "this really is a dollar sign
              > that I want"
              > 0.0 - because we matched one digit numbers only, we are putting in the
              > dollars as 0, a decimal point, and the dimes as zero.
              > $1 - we captured one digit and it goes here. Remember, $1 is our
              variable.
              >
              > Thus, let's say the number was 6c
              >
              > We captured the 6. The "c" gets discarded because it was a part of the
              > regular expression find but was outside of parenthesis.
              >
              > Then we inserted "$0.0" and then "6" which becomes "$0.06"
              >
              > Now, there's no way to tell regular expressions to formulate numbers
              > with leading zeroes, which would be convenient, so we have to write
              > regular expressions for each case where there would be a leading zero.
              >
              > So, the second expression is the same with two changes.
              >
              > First, it matches two digits, not one. (That's the \d\d sequence.)
              >
              > Since we are finding two digits, it doesn't make sense to count zero
              > dimes and then insert a two digit number, so the output only specifies
              > the whole dollar portion (which is 0).
              >
              > For the record, \d\d is functionally equivalent to \d{2} but when
              > matching two to three characters I tend to just specify it like I did.
              > I think it makes it more readable. But neither is more or less correct.
              >
              > Now, I could have ended there and fully answered your request, but I
              > felt that in the event you had a three digit cents specification
              > somewhere that you would want it changed (not likely, but possible) I
              > finished with the last one too. What it does is find anything that is
              > three or greater digits. It saves the last two digits to $2 and
              > everything before that to $1.
              >
              > \b(\d+)(\d\d)c\b
              >
              > Word boundary, Any number of digits (save to $1), two digits (save to
              > $2), the letter "c", word boundary.
              >
              > Then, in the output, since now we have a count of the number of
              > dollars (in the sequence 1234c that would be 12 dollars) we don't
              > specify 0 but rather what we discovered.
              >
              > And there you have it!
              >
              > --Keith
              >
              > (Admins, am I allowed to make a product recommendation that's a cheat
              > sheet for regular expressions?)
              >
              > --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@> wrote:
              > >
              > > Thanks Keith!
              > >
              > > I would love an explanation. Teach a man to fish...
              > >
              > > --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@> wrote:
              > > >
              > > > In a new clip, use:
              > > >
              > > > ^!REPLACE "\b(\d)c\b" >> "\$0.0$1" AWRS
              > > > ^!REPLACE "\b(\d\d)c\b" >> "\$0.$1" AWRS
              > > > ^!REPLACE "\b(\d+)(\d\d)c\b" >> "\$$1.$2" AWRS
              > > >
              > > > If you want me to explain the regular expressions, just say the
              word.
              > > > --Keith
              > > >
              > > > --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@> wrote:
              > > > >
              > > > > Hi guys,
              > > > >
              > > > > I'm looking to write a simple clip that searches through a
              block of
              > > > > text and replaces all instances of monetary notation that look
              like
              > > > this:
              > > > >
              > > > > 44c
              > > > >
              > > > > with this
              > > > >
              > > > > $0.44.
              > > > >
              > > > > Here's what the block might look like before changes:
              >
            • dracorat
              Aye it should. Every once in a while, the keyboard order enters my mind instead of the real person order. Sorry. --Keith
              Message 6 of 7 , Apr 27, 2008
                Aye it should. Every once in a while, the keyboard order enters my
                mind instead of the "real person" order. Sorry.

                --Keith

                --- In ntb-clips@yahoogroups.com, "jane_sedgewick"
                <jane_sedgewick@...> wrote:
                >
                > I'm not sure about your boundary definition as
                > ^|$|[^1-0a-zA-Z_]
                > I don't understand the 1-0 part. Shouldn't it be 0-9?
                > As in ^|$|[^0-9a-zA-Z_]
              • ehofferino
                Thanks Keith! It s going to take me a while to digest this... ;-) ... variable. ... word. ... block of ... like
                Message 7 of 7 , Apr 27, 2008
                  Thanks Keith! It's going to take me a while to digest this... ;-)



                  --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@...> wrote:
                  >
                  > You bet!
                  >
                  > In the find expression (what's left of >>)
                  >
                  > \b means "boundary" and matches the outer edges of any alpha numeric
                  > sequence. It is close (but not exactly like) to the equation
                  > ^|$|[^1-0a-zA-Z_]
                  >
                  > (If your regular expression understanding is not yet up to
                  > understanding that, just remember, edges of words)
                  >
                  > So, by wrapping a regular expression in \b on both sides we force
                  > whole word matches (or in this case, whole number sequences.)
                  >
                  > So, starting the explanation again:
                  > \b - beginning of word
                  > ( - What's about to come, take note of
                  > \d - a single decimal character
                  > ) - stop taking note - from ( to ) we have our first "match" which in
                  > the output gets assigned to the variable $1
                  > c - this is a literal character because it doesn't have a backslash
                  > with it. So, we are telling it to find the letter "c". If we had the
                  > "c" in the parenthesis it would be a part of the $1 variable, which
                  > means it would be copied to the output and we don't want that. That's
                  > why it's outside the parenthesis.
                  > \b - end of word (so we don't match something like 2c2 for example. Or
                  > 2cell or anything else that's not one digit and a letter "c".)
                  >
                  > Then, in the output (the area to the right of >>) we have to tell it
                  > what to do with what we found. Remember we saved the number as $1.
                  >
                  > \$ - because the dollar sign is usually special to regular
                  > expressions, we have to tell it that we really want a dollar sign. So
                  > it has a backslash before it which means "this really is a dollar sign
                  > that I want"
                  > 0.0 - because we matched one digit numbers only, we are putting in the
                  > dollars as 0, a decimal point, and the dimes as zero.
                  > $1 - we captured one digit and it goes here. Remember, $1 is our
                  variable.
                  >
                  > Thus, let's say the number was 6c
                  >
                  > We captured the 6. The "c" gets discarded because it was a part of the
                  > regular expression find but was outside of parenthesis.
                  >
                  > Then we inserted "$0.0" and then "6" which becomes "$0.06"
                  >
                  > Now, there's no way to tell regular expressions to formulate numbers
                  > with leading zeroes, which would be convenient, so we have to write
                  > regular expressions for each case where there would be a leading zero.
                  >
                  > So, the second expression is the same with two changes.
                  >
                  > First, it matches two digits, not one. (That's the \d\d sequence.)
                  >
                  > Since we are finding two digits, it doesn't make sense to count zero
                  > dimes and then insert a two digit number, so the output only specifies
                  > the whole dollar portion (which is 0).
                  >
                  > For the record, \d\d is functionally equivalent to \d{2} but when
                  > matching two to three characters I tend to just specify it like I did.
                  > I think it makes it more readable. But neither is more or less correct.
                  >
                  > Now, I could have ended there and fully answered your request, but I
                  > felt that in the event you had a three digit cents specification
                  > somewhere that you would want it changed (not likely, but possible) I
                  > finished with the last one too. What it does is find anything that is
                  > three or greater digits. It saves the last two digits to $2 and
                  > everything before that to $1.
                  >
                  > \b(\d+)(\d\d)c\b
                  >
                  > Word boundary, Any number of digits (save to $1), two digits (save to
                  > $2), the letter "c", word boundary.
                  >
                  > Then, in the output, since now we have a count of the number of
                  > dollars (in the sequence 1234c that would be 12 dollars) we don't
                  > specify 0 but rather what we discovered.
                  >
                  > And there you have it!
                  >
                  > --Keith
                  >
                  > (Admins, am I allowed to make a product recommendation that's a cheat
                  > sheet for regular expressions?)
                  >
                  > --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@> wrote:
                  > >
                  > > Thanks Keith!
                  > >
                  > > I would love an explanation. Teach a man to fish...
                  > >
                  > > --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@> wrote:
                  > > >
                  > > > In a new clip, use:
                  > > >
                  > > > ^!REPLACE "\b(\d)c\b" >> "\$0.0$1" AWRS
                  > > > ^!REPLACE "\b(\d\d)c\b" >> "\$0.$1" AWRS
                  > > > ^!REPLACE "\b(\d+)(\d\d)c\b" >> "\$$1.$2" AWRS
                  > > >
                  > > > If you want me to explain the regular expressions, just say the
                  word.
                  > > > --Keith
                  > > >
                  > > > --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@> wrote:
                  > > > >
                  > > > > Hi guys,
                  > > > >
                  > > > > I'm looking to write a simple clip that searches through a
                  block of
                  > > > > text and replaces all instances of monetary notation that look
                  like
                  > > > this:
                  > > > >
                  > > > > 44c
                  > > > >
                  > > > > with this
                  > > > >
                  > > > > $0.44.
                  > > > >
                  > > > > Here's what the block might look like before changes:
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.