cjohnson300
asked on
Match one string but not another
Can anyone help me to write a regular expression that matches "ecard", but not "scorecard" (without the double quotes)
Many thanks
Many thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try "^ecard". ^ indicates the match must start with e.
"[\ ]ecard[\ ]"
gives exactly "ecard"
I'm trying to make it work for following conditions (which currently dont work):
ecard at the begining or end of the line.
gives exactly "ecard"
I'm trying to make it work for following conditions (which currently dont work):
ecard at the begining or end of the line.
got it!!!
"\b[e][c][a][r][d]\b"
hope this is what u wanted
"\b[e][c][a][r][d]\b"
hope this is what u wanted
ASKER
I selected this answer because it was the first and it had the desired results
No problems as far as the solution works.
But i thaught my solution was more accurate.
I'm ok with any decision!
But i thaught my solution was more accurate.
I'm ok with any decision!
I have to agree ozo's answer is most elegant!