Using regex, I'm trying to match any
string of characters that meets the following conditions (in the order
displayed):
- Contains
a dollar sign$
; then - at least
one letter[a-zA-Z]
; then - zero
or more letters, numbers, underscores, periods (dots), opening brackets, and/or closing
brackets[a-zA-Z0-9_.\[\]]*
;
then - one pipe character
|
;
then - one at sign
@
;
then - at least one letter
[a-zA-Z]
; then - zero or more
letters, numbers, and/or underscores[a-zA-Z0-9_]*
;
then - zero colons
:
In
other words, if a colon is found at the end of the string, then it should
not count as a
match.
Here are some examples of valid
matches:
$tmp1|@hello
$x2.h|@hi_th3re
Valid
match$here|@in_the middle of other
characters
And
here are some examples of invalid
matches:
$tmp2|@not_a_match:"because
there is a
colon"
$c.4a|@also_no_match:
Here
are some of the patterns I've
tried:
(\$[a-zA-Z])([a-zA-Z0-9_.\[\]]*)(\|@)([a-zA-Z][a-zA-Z0-9_]*(?!.[:]))
(\$[a-zA-Z])([a-zA-Z0-9_.\[\]]+)?(\|@)([a-zA-Z][a-zA-Z0-9_]*(?![:]))
(\$[a-zA-Z])([a-zA-Z0-9_.\[\]]+)?(\|@)([a-zA-Z][a-zA-Z0-9_]*)([^:])
No comments:
Post a Comment