Conversation

Notices

  1. Anyone good at regular expressions? How do I say "match this string unless it also matches this other string"?

    Monday, 04-Feb-13 12:05:51 UTC from web
    1. @toksyuryel You can match my string any day

      Monday, 04-Feb-13 12:06:18 UTC from web
      1. @mrdragon Let me just slip into this Spitfire costume…

        Monday, 04-Feb-13 12:16:04 UTC from web
        1. @toksyuryel Sure you don't want me in that?

          Monday, 04-Feb-13 12:21:59 UTC from web
          1. @mrdragon I thought you wanted Spitfire, not wanted to BE Spitfire?

            Monday, 04-Feb-13 12:23:36 UTC from web
            1. @toksyuryel Why not change it up for once?

              Monday, 04-Feb-13 12:25:53 UTC from web
              1. @mrdragon Why don't you both wear the suits? *grins deviously*

                Monday, 04-Feb-13 12:29:09 UTC from MuSTArDroid
                1. @bitshift Because let's be honest, they wouldn't be on long

                  Monday, 04-Feb-13 12:32:16 UTC from web
                  1. @mrdragon If you take them off you're doing it wrong.

                    Monday, 04-Feb-13 12:33:00 UTC from web
                    1. @toksyuryel *ripped off

                      Monday, 04-Feb-13 12:38:40 UTC from web
                      1. @mrdragon If you remove them you're doing it wrong. #

                        Monday, 04-Feb-13 12:39:55 UTC from web
                  2. @mrdragon Oh, wouldn't they~? You underestimate how... persuasive I can be.

                    Monday, 04-Feb-13 12:43:18 UTC from MuSTArDroid
                    1. @bitshift I'm an animal

                      Monday, 04-Feb-13 12:48:53 UTC from web
                      1. @mrdragon I bet you are~

                        Monday, 04-Feb-13 12:52:58 UTC from MuSTArDroid
                        1. @bitshift Oh my

                          Monday, 04-Feb-13 12:53:38 UTC from web
                          1. @mrdragon http://ur1.ca/cp0ps

                            Monday, 04-Feb-13 13:03:02 UTC from MuSTArDroid
                            1. @bitshift http://rainbowdash.net/attachment/168038

                              Monday, 04-Feb-13 13:05:26 UTC from web
                              1. @mrdragon http://ur1.ca/cp0vu

                                Monday, 04-Feb-13 13:13:33 UTC from MuSTArDroid
                                1. @bitshift http://rainbowdash.net/attachment/168048

                                  Monday, 04-Feb-13 13:18:44 UTC from web
                                  1. @mrdragon http://ur1.ca/cp0zo

                                    Monday, 04-Feb-13 13:21:52 UTC from MuSTArDroid
                                    1. @bitshift http://rainbowdash.net/attachment/168050

                                      Monday, 04-Feb-13 13:23:31 UTC from web
    2. @toksyuryel Put the parts which aren't allowed in a [^] block?

      Monday, 04-Feb-13 12:08:49 UTC from MuSTArDroid
      1. @bitshift The problem arises from needing to check that the string to match is not contained within the string to not match. Specifically, I am trying to match the first # symbol that is not inside quotes.

        Monday, 04-Feb-13 12:10:27 UTC from web
    3. @toksyuryel Might be easier to come up with a concise one if I knew what the specific strings were.

      Monday, 04-Feb-13 12:10:27 UTC from MuSTArDroid
      1. @bitshift The string to match is '\s*#.*' and the string to not match is '".*#.*"'

        Monday, 04-Feb-13 12:11:16 UTC from web
        1. @bitshift I recognize that this breaks when a quote is escaped, but I'd like to take this one step at a time (and I found a snippet that allows for escaped quotes so hopefully finding the solution to the simpler problem will teach me whatever I need to know to work that into the final result).

          Monday, 04-Feb-13 12:13:02 UTC from web
        2. @toksyuryel Hmm... '[^"]*#[^"]*' ?

          Monday, 04-Feb-13 12:16:56 UTC from MuSTArDroid
          1. @bitshift This will match when there is a quote character after the # even if there isn't one before it. (I am being generous here- this actually barely matches anything at all, but I understand what you meant to type)

            Monday, 04-Feb-13 12:19:04 UTC from web
            1. @toksyuryel Ah, yes. I think you'd have to use a look-backward expression, if that's even available. I don't see why it'd match very little, though; the [^"] blocks ought to match any non-" character.

              Monday, 04-Feb-13 12:22:20 UTC from MuSTArDroid
              1. @bitshift You didn't allow for any characters to separate the quotes and the #

                Monday, 04-Feb-13 12:23:11 UTC from web
                1. @toksyuryel Oh, right. Sorry, I'm not so good without access to a reference and/or a means of testing.

                  Monday, 04-Feb-13 12:25:42 UTC from MuSTArDroid
                2. @toksyuryel Maybe I could help with this when I get home, if you're still stuck?

                  Monday, 04-Feb-13 12:28:09 UTC from MuSTArDroid
                  1. @bitshift Sounds good *hug*

                    Monday, 04-Feb-13 12:28:54 UTC from web
                    1. @toksyuryel In the meantime, if the flavour of regex you're using (I assume grep's) supports enough of it, I suggest http://www.regular-expressions.info/lookaround.html

                      Monday, 04-Feb-13 12:31:17 UTC from MuSTArDroid
                      1. @bitshift sed actually

                        Monday, 04-Feb-13 12:33:13 UTC from web
                      2. @bitshift According to that article, you can't use repetition or optional items inside a lookbehind.

                        Monday, 04-Feb-13 12:39:33 UTC from web
                        1. @toksyuryel Dang. I'll leave it until I get home and can have a proper think about it, then.

                          Monday, 04-Feb-13 12:44:03 UTC from MuSTArDroid
        3. @toksyuryel This would be a lot easier if I had a way to test on mobile, heh. I /think/ that ought to work, though.

          Monday, 04-Feb-13 12:18:24 UTC from MuSTArDroid
        4. @bitshift I have recognized a flaw in my comparison idea which basically means it's not going to work anyway even if there was a way to do it that way. It looks like what I actually need to do is count up the number of quotes, and only match if an even number of quotes precedes the first # and I don't think that's something a regular expression can do. Time to break out awk.

          Monday, 04-Feb-13 13:50:27 UTC from web
          1. @toksyuryel I really need to learn how to work with that, heh. I'm continually amazed by what it can do in the right hands. :)

            Monday, 04-Feb-13 14:02:40 UTC from MuSTArDroid
          2. @toksyuryel I think a regex with sufficiently strong lookaround capabilities probably could. It'd be a horrendous mess, though, so far better to break out awk. :)

            Monday, 04-Feb-13 14:03:55 UTC from MuSTArDroid
            1. @bitshift No amount of lookaround will satisfy this case: VAR="quoted value" # comment with an "embedded quote" in it

              Monday, 04-Feb-13 14:06:55 UTC from web
              1. @toksyuryel If you did multiple alternatives via non-capturing groups, I think you could just about do it. It would be a terrible, terrible idea, is all. :b

                Monday, 04-Feb-13 14:09:28 UTC from MuSTArDroid
          3. @toksyuryel But yeah, for sure a regex is not the right tool here.

            Monday, 04-Feb-13 14:07:59 UTC from MuSTArDroid
    4. @snowcone Not really. Pretty vanilla if you ask me.

      Monday, 04-Feb-13 20:40:15 UTC from web
      1. @toksyuryel @snowcone Careful, now, yous twos.

        Monday, 04-Feb-13 20:40:41 UTC from web
        1. @scribus I assume I know where the line is, but I've been wrong before.

          Monday, 04-Feb-13 20:43:24 UTC from web
          1. @toksyuryel I don't distrust you, just giving a heads up.

            Monday, 04-Feb-13 20:45:05 UTC from web
            1. @scribus I generally use "Boast Busters" and "Putting Your Hoof Down" as a yardstick for what's acceptable. Do you feel that's accurate?

              Monday, 04-Feb-13 20:48:39 UTC from web
              1. @scribus Could probably include "A Canterlot Wedding" in that list too, now that I think on it.

                Monday, 04-Feb-13 20:49:15 UTC from web
                1. @toksyuryel Anything that can be cited in the show will almost certainly be cool. (Not saying "definitely" because I don't want anyone dropping racism on us and saying "But they were racist against Zecora, so it must be fine to be racist!" or anything similar) :P

                  Monday, 04-Feb-13 20:57:18 UTC from web
                  1. @scribus # # rule-bending alla Applejack evading her Pinkie promise

                    Monday, 04-Feb-13 20:58:36 UTC from web
                    1. @pony # # Social ineptitude alla Pinkie Pie

                      Monday, 04-Feb-13 21:01:41 UTC from web
                      1. @pony "à la". 's French. :)

                        Monday, 04-Feb-13 22:20:27 UTC from web
                        1. @bitshift ah thank you x3 My italian messes up my french

                          Monday, 04-Feb-13 22:22:04 UTC from web