Conversation
Notices
-
@snowcone Not really. Pretty vanilla if you ask me.
Monday, 04-Feb-13 20:40:15 UTC from web-
Anyone good at regular expressions? How do I say "match this string unless it also matches this other string"?
-
@toksyuryel You can match my string any day
-
@toksyuryel Put the parts which aren't allowed in a [^] block?
-
@toksyuryel Might be easier to come up with a concise one if I knew what the specific strings were.
-
@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.
-
@bitshift The string to match is '\s*#.*' and the string to not match is '".*#.*"'
-
@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).
-
@mrdragon Let me just slip into this Spitfire costume…
-
@toksyuryel Hmm... '[^"]*#[^"]*' ?
-
@toksyuryel This would be a lot easier if I had a way to test on mobile, heh. I /think/ that ought to work, though.
-
@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)
-
@toksyuryel Sure you don't want me in that?
-
@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.
-
@bitshift You didn't allow for any characters to separate the quotes and the #
-
@mrdragon I thought you wanted Spitfire, not wanted to BE Spitfire?
-
@toksyuryel Oh, right. Sorry, I'm not so good without access to a reference and/or a means of testing.
-
@toksyuryel Why not change it up for once?
-
@toksyuryel Maybe I could help with this when I get home, if you're still stuck?
-
@bitshift Sounds good *hug*
-
@mrdragon Why don't you both wear the suits? *grins deviously*
Toksyuryel likes this. -
@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
-
@bitshift Because let's be honest, they wouldn't be on long
-
@mrdragon If you take them off you're doing it wrong.
-
@bitshift sed actually
-
@toksyuryel *ripped off
-
@bitshift According to that article, you can't use repetition or optional items inside a lookbehind.
-
@mrdragon Oh, wouldn't they~? You underestimate how... persuasive I can be.
-
@toksyuryel Dang. I'll leave it until I get home and can have a proper think about it, then.
-
@bitshift I'm an animal
Eris likes this. -
@mrdragon I bet you are~
-
@bitshift Oh my
Bit Shift likes this. -
Toksyuryel likes this.
-
Toksyuryel and Bit Shift like this.
-
Toksyuryel likes this.
-
Toksyuryel and Bit Shift like this.
-
Toksyuryel likes this.
-
Toksyuryel likes this.
-
@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.
-
@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. :)
-
@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. :)
-
@bitshift No amount of lookaround will satisfy this case: VAR="quoted value" # comment with an "embedded quote" in it
-
@toksyuryel But yeah, for sure a regex is not the right tool here.
-
@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
-
@toksyuryel @snowcone Careful, now, yous twos.
-
@scribus I assume I know where the line is, but I've been wrong before.
-
@toksyuryel I don't distrust you, just giving a heads up.
-
@scribus I generally use "Boast Busters" and "Putting Your Hoof Down" as a yardstick for what's acceptable. Do you feel that's accurate?
-
@scribus Could probably include "A Canterlot Wedding" in that list too, now that I think on it.
-
@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
-
@pony "à la". 's French. :)
-
@bitshift ah thank you x3 My italian messes up my french
-