Can I make a regex match all characters up to ; except \;? -
i going construct message-passing system messages have following structure:
message type;message content   (matches message type;)
however, user can set message type, , (for sake of loosely coupled systems) want allow them use ; part of message type. this, i'll have message constructor escape \:
tl\;dr;too long; didn't read content   (matches tl\;dr;)
how can have regex match content first ; that's not \;? in example, that's tl\;dr; part only. note there can unescaped ; within message content.
i tried ^.*;, matches content semicolon within message (e.g. tl\;dr;too long;)
/.*?[^\\](?=;)/   you use ; instead of (?=;), latter prevents being part of full match.
if want match start of string, use:
/^.*?[^\\](?=;)/      
Comments
Post a Comment